Explorar o código

客户端-增加将所有用户令牌设置为失效接口

sunxbiao hai 11 meses
pai
achega
9b868df3a1
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      app/common/repositories/user/UserRepository.php

+ 4 - 2
app/common/repositories/user/UserRepository.php

@@ -1430,8 +1430,10 @@ class UserRepository extends BaseRepository
1430
     public function checkToken(string $token)
1430
     public function checkToken(string $token)
1431
     {
1431
     {
1432
         $has = Cache::has('user_' . $token);
1432
         $has = Cache::has('user_' . $token);
1433
-        if (!$has)
1434
-            throw new AuthException('无效的token');
1433
+        if (!$has) {
1434
+            throw new ValidateException('请登录');
1435
+            // throw new AuthException('无效的token');
1436
+        }
1435
         $lastTime = Cache::get('user_' . $token);
1437
         $lastTime = Cache::get('user_' . $token);
1436
         if (($lastTime + intval(Config::get('admin.token_valid_exp', 15)) * 60) > time())
1438
         if (($lastTime + intval(Config::get('admin.token_valid_exp', 15)) * 60) > time())
1437
             throw new AuthException('token 已过期');
1439
             throw new AuthException('token 已过期');