Example #1
0
 /**
  * @test
  */
 public function findByEmailAndPassword()
 {
     $user1 = User::findByEmailAndPassword("*****@*****.**", "test1");
     $this->isFalse($user1->isSelected());
     $user1 = User::findByEmailAndPassword("*****@*****.**", "test1");
     $this->isTrue($user1->isSelected());
 }
Example #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");
         }
     }
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user = User::findByEmailAndPassword(Input::get('username'), Input::get('password'));
     if (!isset($user)) {
         return Response::json(array('error' => Config::get('constants.STATUS_CODES.USER.USER_NOT_EXISTS'), 'error_description' => 'User does not exist'), 403);
     } elseif (!$user->activated) {
         return Response::json(array('error' => Config::get('constants.STATUS_CODES.USER.NEED_ACTIVATED'), 'error_description' => 'You need to activate your account', 'data' => $user->toArray()), 403);
     } else {
         try {
             $obj = Authorizer::issueAccessToken();
             $access_token = $obj['access_token'];
             User::invalidOldTokens($access_token);
             return Response::json($obj);
         } catch (\League\OAuth2\Server\Exception\OAuthException $exception) {
             //\Log::error($exception);
             return Response::json(array('error' => $exception->errorType, 'error_description' => $exception->getMessage()), 403);
         }
     }
 }