Beispiel #1
0
 public function getRefresh(JWTAuth $jwt)
 {
     try {
         $token = $jwt->refresh($jwt->getToken());
     } catch (JWTException $e) {
         return $this->jsonResponse(null, 401);
     }
     return $this->jsonResponse(['token' => $token]);
 }
Beispiel #2
0
 /**
  * @param JWTAuth $jwt
  * @return JsonResponse
  */
 public function getRefresh(JWTAuth $jwt)
 {
     if ($jwt->getToken()) {
         try {
             return new JsonResponse(['token' => $jwt->refresh()]);
         } catch (JWTException $e) {
             return new JsonResponse(['error' => $e->getMessage()], 401);
         }
     }
     return new JsonResponse(['error' => 'Could not refresh token'], 401);
 }
Beispiel #3
0
 /** @test */
 public function it_should_retrieve_the_token_from_the_query_string()
 {
     $request = Request::create('/foo', 'GET', ['token' => 'foo.bar.baz']);
     $jwtAuth = new JWTAuth($this->manager, $this->user, $this->auth, $request);
     $this->assertInstanceOf('Tymon\\JWTAuth\\Token', $jwtAuth->parseToken()->getToken());
     $this->assertEquals($jwtAuth->getToken(), 'foo.bar.baz');
 }
 /**
  * Get the token.
  *
  * @return bool|string 
  * @static 
  */
 public static function getToken()
 {
     return \Tymon\JWTAuth\JWTAuth::getToken();
 }
Beispiel #5
0
 public function __construct(Repository $cache, JWTAuth $jwtAuth)
 {
     $this->cache = $cache;
     $this->user = $jwtAuth->toUser($jwtAuth->getToken());
 }