當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JWTAuth::refresh方法代碼示例

本文整理匯總了PHP中Tymon\JWTAuth\Facades\JWTAuth::refresh方法的典型用法代碼示例。如果您正苦於以下問題:PHP JWTAuth::refresh方法的具體用法?PHP JWTAuth::refresh怎麽用?PHP JWTAuth::refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tymon\JWTAuth\Facades\JWTAuth的用法示例。


在下文中一共展示了JWTAuth::refresh方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: refresh

 public function refresh()
 {
     $oldtoken = JWTAuth::getToken();
     try {
         // attempt to refresh token for the user
         if (!($token = JWTAuth::refresh($oldtoken))) {
             return $this->response->array(['error' => 'invalid_token'], 401);
         }
     } catch (JWTException $e) {
         return $this->response->array(['error' => 'could_not_refresh_token'], 500);
     }
     return $this->response->array(compact('token'));
 }
開發者ID:Bouhnosaure,項目名稱:lia-api,代碼行數:13,代碼來源:JwtController.php

示例2: refreshToken

 /**
  * @return mixed
  */
 public function refreshToken()
 {
     $token = JWTAuth::getToken();
     if (!$token) {
         return $this->apiResponse(400, ['message' => TOKEN_NOT_PROVIDED]);
     }
     try {
         $token = JWTAuth::refresh($token);
     } catch (TokenInvalidException $e) {
         return $this->apiResponse(401, ['message' => TOKEN_INVALID]);
     }
     return $this->apiResponse(200, ['message' => TOKEN_REFRESHED, 'token' => $token]);
 }
開發者ID:Worklemon,項目名稱:api,代碼行數:16,代碼來源:AuthController.php

示例3: refresh

 /**
  * Refresh current expired token.
  *
  * @return string
  */
 public function refresh()
 {
     $this->parseToken();
     return JWTAuth::refresh();
 }
開發者ID:imjerrybao,項目名稱:jwt-auth-guard,代碼行數:10,代碼來源:JwtAuthGuard.php

示例4: refreshToken

 /**
  * Refresh Token
  * Invalidate the token, so user cannot use it anymore
  * and return a new token
  * 
  * @param Request $request
  */
 public function refreshToken()
 {
     try {
         if (!($token = JWTAuth::getToken())) {
             return response()->json(['error' => 'Token not provided'], 400);
         }
     } catch (Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
         return response()->json(['token_expired'], $e->getStatusCode());
     } catch (Tymon\JWTAuth\Exceptions\TokenInvalidException $e) {
         return response()->json(['token_invalid'], $e->getStatusCode());
     } catch (Tymon\JWTAuth\Exceptions\JWTException $e) {
         return response()->json(['token_absent'], $e->getStatusCode());
     }
     /*
     $token = JWTAuth::getToken();
     if(!$token){
     	//throw new BadRequestHtttpException('Token not provided');
                 return response()->json(['error' => 'Token not provided'], 400);			
     }
     */
     try {
         $token = JWTAuth::refresh($token);
     } catch (TokenInvalidException $e) {
         //throw new AccessDeniedHttpException('The token is invalid');
         return response()->json(['error' => 'The token is invalid'], 400);
     }
     return response()->json(compact('token'));
 }
開發者ID:Vladimir-Florian,項目名稱:Pasu,代碼行數:35,代碼來源:UserController.php


注:本文中的Tymon\JWTAuth\Facades\JWTAuth::refresh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。