Exemple #1
0
 public function actionAsync()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     // get the login form model
     $model = new LoginForm();
     Yii::$app->session->remove('secureId');
     // see if values are sent via post
     if (Yii::$app->request->post('login')) {
         $model->attributes = Yii::$app->request->post('login');
         if (($userObject = $model->login()) !== false) {
             if ($this->module->secureLogin) {
                 if ($model->sendSecureLogin()) {
                     Yii::$app->session->set('secureId', $model->getUser()->id);
                     return ['refresh' => false, 'errors' => false, 'enterSecureToken' => true];
                 } else {
                     // misc error while secure token sent ?!
                 }
             } else {
                 if (Yii::$app->adminuser->login($userObject)) {
                     return ['refresh' => true, 'errors' => false, 'enterSecureToken' => false];
                 } else {
                     // misc error while login ?!
                 }
             }
         }
     }
     return ['refresh' => false, 'errors' => $model->getErrors(), 'enterSecureToken' => false];
 }
Exemple #2
0
 public function actionLogin()
 {
     $this->layout = 'login';
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goHome();
     } else {
         return $this->render('log', ['model' => $model]);
     }
 }