Esempio n. 1
0
 public static function get($token = null)
 {
     $token = is_null($token) ? Token::find() : $token;
     $key = config('jwt.key');
     // 密钥
     $alg = config('jwt.alg') ? config('jwt.alg') : 'HS256';
     // 算法
     if ($token) {
         try {
             if ($claims = JWT::decode($token, $key, array($alg))) {
                 return $claims;
             }
         } catch (\InvalidArgumentException $e) {
             data()->setErr('token', '服务器设置错误: ' . $e->getMessage())->status(500);
         } catch (\Exception $e) {
             data()->setErr('token', '无效的TOKEN: ' . $e->getMessage())->status(403);
         }
     }
     return null;
 }
Esempio n. 2
0
File: JWT.php Progetto: alpfish/alp
 public static function touch($token = null)
 {
     return Token::touch($token);
 }