Example #1
0
 public function testLoginCorrect()
 {
     $model = new LoginForm(['username' => 'bayer.hudson', 'password' => 'password_0']);
     $this->specify('user should be able to login with correct credentials', function () use($model) {
         expect('model should login user', $model->login())->true();
         expect('error message should not be set', $model->errors)->hasntKey('password');
         expect('user should be logged in', Yii::$app->user->isGuest)->false();
     });
 }
Example #2
0
 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->login()) {
             $this->trigger(AdminLogEvent::EVENT_SUCCESS_AUTH);
             return $this->goBack(Yii::$app->request->pathInfo);
         } else {
             $this->trigger(AdminLogEvent::EVENT_WRONG_AUTH);
         }
     }
     return $this->render('login', ['model' => $model]);
 }
Example #4
0
 public function actionLogin()
 {
     Yii::$app->layout = 'dwz_login';
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         if ($model->load(Yii::$app->request->post()) && $model->login()) {
             Yii::$app->session->setFlash('success', 'success login.');
             return $this->goBack();
         } else {
             Yii::$app->session->setFlash('error', $model->getErrors());
             return $this->redirect('login');
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }