Пример #1
0
 public function login()
 {
     $data = $this->getData();
     $this->validateParams($data);
     $auth = Auth::where('email', $data['email'])->first();
     if ($auth) {
         if ($auth->password != Auth::password_hash($data['password'], $auth->password_salt)) {
             throw new Exceptions\ForbiddenException("password_invalid");
         }
         $auth->setTrustedAction(true);
         return $auth->dataWithToken();
     } else {
         throw new Exceptions\ForbiddenException("invalid_user");
     }
 }
Пример #2
0
 public function login()
 {
     $data = $this->getData();
     $this->validateParams($data);
     $auth = Auth::where('email', $data['email'])->first();
     if ($auth) {
         if ($auth->password != Auth::password_hash($data['password'], $auth->password_salt)) {
             throw new Exceptions\ForbiddenException("password_invalid");
         }
         $auth->setTrustedAction(true);
         //
         // Handle login with custom method.
         //
         $observer = Auth::getObserver();
         if ($observer && method_exists($observer, 'login') && !$observer->login($auth)) {
             throw new Exceptions\ForbiddenException();
         }
         return $auth->dataWithToken();
     } else {
         throw new Exceptions\ForbiddenException("invalid_user");
     }
 }