Exemplo n.º 1
0
 /**
  * @test
  */
 public function findByUsernameAndPassword()
 {
     $user1 = User::findByUsernameAndPassword("test1", "foo");
     $this->isFalse($user1->isSelected());
     $user1 = User::findByUsernameAndPassword("test1", "test1");
     $this->isTrue($user1->isSelected());
 }
Exemplo n.º 2
0
 /**
  * @httpMethod post
  *
  * @check username_or_email required
  * @check password required
  */
 public function doLogin()
 {
     if ($this->validator->hasError()) {
         $this->view->setName("prepare");
     } else {
         if (strpos($this->username_or_email, "@") === false) {
             $aUser = User::findByUsernameAndPassword($this->username_or_email, $this->password);
         } else {
             $aUser = User::findByEmailAndPassword($this->username_or_email, $this->password);
         }
         if ($aUser->isActive()) {
             $this->login($aUser, true);
         } else {
             $this->errors = array("ユーザー名/メールアドレス、パスワードの組み合わせが間違っています");
             $this->view->setName("prepare");
         }
     }
 }