Beispiel #1
0
 /**
  * @param JWTAuth $jwt
  * @return JsonResponse
  */
 public function getStatus(JWTAuth $jwt)
 {
     if ($jwt->getToken() !== false) {
         return new JsonResponse(['user' => $jwt->toUser()]);
     }
     return new JsonResponse(null, 405);
 }
Beispiel #2
0
 public function getIndex(JWTAuth $jwt)
 {
     if ($token = $jwt->getToken()) {
         event(new UserLoggedOut($jwt->toUser($token)));
         $jwt->invalidate($token);
     }
     return $this->jsonResponse(null);
 }
Beispiel #3
0
 public function login(JWTAuth $auth, Request $request)
 {
     $credentials = $request->only('email', 'password');
     $loggedIn = $auth->attempt($credentials);
     if (!$loggedIn) {
         return $this->response->notFound('email or password don\'t match our record');
     }
     $loggedUser = $auth->toUser($loggedIn);
     $active = $this->getCompanyActiveState($loggedUser->getCompanyId());
     if ($active) {
         $loggedUserAbilities = $loggedUser->getAbilities()->lists('name');
         return $this->response->respond(['success' => ['token' => $loggedIn, 'user_id' => $this->encode($loggedUser->id), 'expire_at' => config('jwt.ttl'), 'privileges' => $loggedUserAbilities, 'code' => 200]]);
     } else {
         return $this->response->notFound('your company account is not active');
     }
 }
 /**
  * Find a user using the user identifier in the subject claim.
  *
  * @param bool|string $token
  * @return mixed 
  * @static 
  */
 public static function toUser($token = false)
 {
     return \Tymon\JWTAuth\JWTAuth::toUser($token);
 }
Beispiel #5
0
 public function __construct(JWTAuth $auth)
 {
     $this->auth = $auth;
     $this->currentUser = $auth->toUser();
 }
Beispiel #6
0
 public function __construct(Repository $cache, JWTAuth $jwtAuth)
 {
     $this->cache = $cache;
     $this->user = $jwtAuth->toUser($jwtAuth->getToken());
 }