public function getRefresh(JWTAuth $jwt) { try { $token = $jwt->refresh($jwt->getToken()); } catch (JWTException $e) { return $this->jsonResponse(null, 401); } return $this->jsonResponse(['token' => $token]); }
/** * @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); }
/** @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(); }
public function __construct(Repository $cache, JWTAuth $jwtAuth) { $this->cache = $cache; $this->user = $jwtAuth->toUser($jwtAuth->getToken()); }