Created
August 3, 2017 12:16
-
-
Save vigikaran/070369cf437e593f2ea4713dfe323d93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function refreshAdminToken(Request $request) | |
{ | |
if($this->validRefreshRequest($request)) | |
{ | |
$admin_user_token = $request->input('admin_user_token'); | |
$secretKey = config('jwt.admin'); | |
try{ | |
$decoded = JWT::decode($admin_user_token, $secretKey, ['HS512']); | |
$decoded = (array) JWT::decode($admin_user_token, $secretKey, ['HS512']); | |
$decoded['iat'] = time(); | |
$decoded['nbf'] = time(); | |
$decoded['exp'] = time() + config('jwt.admin_expire'); | |
return ['result' => true,'token' => JWT::encode($decoded, $secretKey,'HS512')]; | |
}catch ( \Firebase\JWT\ExpiredException $e ) { | |
JWT::$leeway = 86400; | |
$decoded = (array) JWT::decode($admin_user_token, $secretKey, ['HS512']); | |
$decoded['iat'] = time(); | |
$decoded['nbf'] = time(); | |
$decoded['exp'] = time() + config('jwt.admin_expire'); | |
return ['result' => true,'token' => JWT::encode($decoded, $secretKey,'HS512')]; | |
}catch ( \Exception $e ){ | |
return ['result' => false, 'error' => 'Something Went Wrong']; | |
} | |
} | |
else | |
{ | |
return ['result' => false, 'error' => 'Invalid Refresh Token']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment