Explorar o código

Merge pull request #1606 from visuddhinanda/laravel

try token验证失败,返回false
visuddhinanda %!s(int64=2) %!d(string=hai) anos
pai
achega
ebb237beeb
Modificáronse 2 ficheiros con 6 adicións e 2 borrados
  1. 1 1
      app/Console/Commands/TestRedis.php
  2. 5 1
      app/Http/Api/AuthApi.php

+ 1 - 1
app/Console/Commands/TestRedis.php

@@ -118,7 +118,7 @@ class TestRedis extends Command
 
         $key = 'cache-key-clusters';
 		$this->info("testing RedisClusters remember()");
-		$value = RedisClusters::remember($key,600,function(){
+		$value = RedisClusters::remember($key,10,function(){
 			return 'cache-key-clusters';
 		});
 		if(RedisClusters::has($key)){

+ 5 - 1
app/Http/Api/AuthApi.php

@@ -15,7 +15,11 @@ class AuthApi{
                 if($token === "null"){
                     return false;
                 }
-                $jwt = JWT::decode($token,new Key(config('app.key'),'HS512'));
+                try{
+                    $jwt = JWT::decode($token,new Key(config('app.key'),'HS512'));
+                }catch(\Exception $e){
+                    return false;
+                }
                 if($jwt->exp < time()){
                     //过期
                     return false;