Ejemplo n.º 1
0
 public function testLoginCorrect()
 {
     $model = new LoginForm(['username' => 'admin', 'password' => 'adminpass']);
     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();
 }
Ejemplo n.º 2
0
 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]);
     }
 }
Ejemplo n.º 3
0
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $this->layout = '//_clear';
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack(Url::to(['/admin']));
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }