public function findAndLoginUser($user)
    {
        $app = $this->getApplication();
        if (!$app->has('user')) {
            throw new ConfigurationException('The user component is not configured');
        }

        if ($user instanceof \yii\web\IdentityInterface) {
            $identity = $user;
        } else {
            // class name implementing IdentityInterface
            $identityClass = $app->user->identityClass;
            $identity = call_user_func([$identityClass, 'findIdentity'], $user);
            if (!isset($identity)) {
                throw new \RuntimeException('User not found');
            }
        }
        $app->user->login($identity);
    }
public function findAndLoginUser($user)
    {
        $app = $this->getApplication();
        if (!$app->has('user')) {
            throw new ConfigurationException('The user component is not configured');
        }

        if ($user instanceof \yii\web\IdentityInterface) {
            $identity = $user;
        } else {
            // class name implementing IdentityInterface
            $identityClass = $app->user->identityClass;
            $identity = call_user_func([$identityClass, 'findIdentity'], $user);
            if (!isset($identity)) {
                throw new \RuntimeException('User not found');
            }
        }
        $app->user->login($identity);
    }
public function findAndLoginUser ( $ user ) { $ app = $ this -> getApplication ( ) ; if ( ! $ app -> has ( 'user' ) ) { throw new ConfigurationException ( 'The user component is not configured' ) ; } if ( $ user instanceof \ yii \ web \ IdentityInterface ) { $ identity = $ user ; } else { // class name implementing IdentityInterface $ identityClass = $ app -> user -> identityClass ; $ identity = call_user_func ( [ $ identityClass , 'findIdentity' ] , $ user ) ; if ( ! isset ( $ identity ) ) { throw new \ RuntimeException ( 'User not found' ) ; } } $ app -> user -> login ( $ identity ) ; }
Finds and logs in a user
@internal
@param $user
@throws ConfigurationException
@throws \RuntimeException
Finds and logs in a user