示例#1
0
 public function testCheck()
 {
     $auth = new Auth();
     $user = new User();
     $user->name = $this->name;
     $user->password = $this->password;
     $auth->login($user);
     $result = $auth->check();
     $this->assertTrue($result);
 }
示例#2
0
 public function actionLogin()
 {
     $userCandidate = new User();
     if (\Yii::$app->request->isPost) {
         $userCandidate->load(\Yii::$app->request->post());
         $auth = new Auth();
         $result = $auth->login($userCandidate);
         if ($result) {
             $this->addMessage('user', 'login_succesfull', Message::INFO);
             return $this->redirect(\Yii::$app->user->getReturnUrl());
         }
         $userCandidate->password = '';
         $this->addMessage('user', 'wrong_data_given', Message::ALERT);
     }
     return $this->render('admin/login.tpl', ['user' => $userCandidate]);
 }