当前位置: 首页>>代码示例>>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;未经允许,请勿转载。