wesmiler 4 năm trước cách đây
mục cha
commit
f9709fc1a2

+ 4 - 4
app/Middleware/Auth/TokenMiddleware.php

@@ -44,21 +44,21 @@ class TokenMiddleware implements MiddlewareInterface
             if (strlen($token) > 0) {
                 $token = JWTUtil::handleToken($token);
                 if ($token == false || !$this->jwt->checkToken($token)) {
-                    throw new TokenValidException(1005, 1002);
+                    throw new TokenValidException(1005, 401);
                 }
 
                 $authId = $token->getClaim('authId');
                 $user = User::where('id', $authId)->where(['enable'=> 'T'])->first();
                 if(!$user){
-                    throw new TokenValidException(1029, 1002);
+                    throw new TokenValidException(1029, 401);
                 }
             }else{
                 //return ApiResource::failed(1010);
-                throw new TokenValidException(1010, 1002);
+                throw new TokenValidException(1010, 401);
             }
 
         } catch (\Exception $exception){
-            throw new TokenValidException(1006, 1002);
+            throw new TokenValidException(1006, 401);
         }
 
 

+ 3 - 0
storage/languages/zh_CN/api.php

@@ -4,6 +4,9 @@ return [
     /* 公共 */
 //    '1001'=> 'ok',
 //    '1002'=> 'err',
+
+    '200'=> 'success',
+    '401'=> 'unauthorized',
     '1001'=> 'success',
     '1002'=> 'error',
     '1003'=> 'exception',