src/controllers/LoginController.php
public function actionAsync()
    {
        if (($lockout = $this->sessionBruteForceLock())) {
            return $this->sendArray(false, [Module::t('login_async_submission_limit_reached', ['time' =>  Yii::$app->formatter->asRelativeTime($lockout)])]);
        }
        
        // get the login form model
        $model = new LoginForm();
        $model->allowedAttempts = $this->module->loginUserAttemptCount;
        $model->lockoutTime = $this->module->loginUserAttemptLockoutTime;
        
        $loginData = Yii::$app->request->post('login');
        Yii::$app->session->remove('secureId');
        // see if values are sent via post
        if ($loginData) {
            $model->attributes = $loginData;
            if (($userObject = $model->login()) !== false) {
                // see if secure login is enabled or not
                if ($this->module->secureLogin) {
                    // try to send the secure token to the given user email store the token in the session.
                    if ($model->sendSecureLogin()) {
                        Yii::$app->session->set('secureId', $model->getUser()->id);
                        return $this->sendArray(false, [], true);
                    }
                    
                    return $this->sendArray(false, ['Unable to send and store secure token.']);
                }
                
                if (Yii::$app->adminuser->login($userObject)) {
                    return $this->sendArray(true);
                }
            }
        }

        return $this->sendArray(false, $model->getErrors(), false);
    }
public function actionAsync()
    {
        if (($lockout = $this->sessionBruteForceLock())) {
            return $this->sendArray(false, [Module::t('login_async_submission_limit_reached', ['time' =>  Yii::$app->formatter->asRelativeTime($lockout)])]);
        }
        
        // get the login form model
        $model = new LoginForm();
        $model->allowedAttempts = $this->module->loginUserAttemptCount;
        $model->lockoutTime = $this->module->loginUserAttemptLockoutTime;
        
        $loginData = Yii::$app->request->post('login');
        Yii::$app->session->remove('secureId');
        // see if values are sent via post
        if ($loginData) {
            $model->attributes = $loginData;
            if (($userObject = $model->login()) !== false) {
                // see if secure login is enabled or not
                if ($this->module->secureLogin) {
                    // try to send the secure token to the given user email store the token in the session.
                    if ($model->sendSecureLogin()) {
                        Yii::$app->session->set('secureId', $model->getUser()->id);
                        return $this->sendArray(false, [], true);
                    }
                    
                    return $this->sendArray(false, ['Unable to send and store secure token.']);
                }
                
                if (Yii::$app->adminuser->login($userObject)) {
                    return $this->sendArray(true);
                }
            }
        }

        return $this->sendArray(false, $model->getErrors(), false);
    }
public function actionAsync ( ) { if ( ( $ lockout = $ this -> sessionBruteForceLock ( ) ) ) { return $ this -> sendArray ( false , [ Module :: t ( 'login_async_submission_limit_reached' , [ 'time' => Yii :: $ app -> formatter -> asRelativeTime ( $ lockout ) ] ) ] ) ; } // get the login form model $ model = new LoginForm ( ) ; $ model -> allowedAttempts = $ this -> module -> loginUserAttemptCount ; $ model -> lockoutTime = $ this -> module -> loginUserAttemptLockoutTime ; $ loginData = Yii :: $ app -> request -> post ( 'login' ) ; Yii :: $ app -> session -> remove ( 'secureId' ) ; // see if values are sent via post if ( $ loginData ) { $ model -> attributes = $ loginData ; if ( ( $ userObject = $ model -> login ( ) ) !== false ) { // see if secure login is enabled or not if ( $ this -> module -> secureLogin ) { // try to send the secure token to the given user email store the token in the session. if ( $ model -> sendSecureLogin ( ) ) { Yii :: $ app -> session -> set ( 'secureId' , $ model -> getUser ( ) -> id ) ; return $ this -> sendArray ( false , [ ] , true ) ; } return $ this -> sendArray ( false , [ 'Unable to send and store secure token.' ] ) ; } if ( Yii :: $ app -> adminuser -> login ( $ userObject ) ) { return $ this -> sendArray ( true ) ; } } } return $ this -> sendArray ( false , $ model -> getErrors ( ) , false ) ; }
Async single sign in action.

This action is triggered by the async request from the login form.

If successfull and 2FA is enabled, a token will be stored and sent to the user's email.

@return array
Async single sign in action .