浏览代码

新增用户权限被修改异常提示

songxinlu 3 年之前
父节点
当前提交
cd1460b6b9

+ 4 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -42,8 +42,11 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
             int res = tokenFacade.newVerifyToken(tokenStr, 1);
             if (-1 == res) {
                 throw new CommonException(ServiceErrorCode.LONGIN_ERROE);
+            } else if (-2 == res) {
+                throw new CommonException(ServiceErrorCode.USER_POWER_UP);
             }
         }
+
         if (matchPermitAllUrl(request)) {
             return;
         }
@@ -348,6 +351,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
         }
         return false;
     }
+
     private boolean matchNotCheckUrl(HttpServletRequest request) {
         if (matchers("/swagger/**", request)
                 || matchers("/v2/**", request)

+ 1 - 0
src/main/java/com/diagbot/exception/ServiceErrorCode.java

@@ -13,6 +13,7 @@ public enum ServiceErrorCode implements ErrorCode {
     GET_TOKEN_FAIL("10020002", "获取token失败"),
     TOKEN_IS_NOT_MATCH_USER("10020003", "请使用自己的token进行接口请求"),
     LONGIN_ERROE("10020012", "您的账号在其它地方已登录,您已被迫下线,请重新登录。如非本人授权,登录后请及时修改密码。"),
+    USER_POWER_UP("10020012", "您的权限已被管理员修改,您已被迫下线,请重新登录。"),
     LONGIN_TOKEN_ERROE("10020013", "登录异常"),
 
     SMS_SEND_ERROR("10020004", "短信发送错误"),

+ 1 - 1
src/main/java/com/diagbot/service/impl/SysTokenServiceImpl.java

@@ -175,7 +175,7 @@ public class SysTokenServiceImpl implements SysTokenService {
                 }
             }
         } else {
-            res = -1;
+            res = -2;       //redis取不到token原因是因为用户权限修改被清空掉了,如果是到时钱被清空会先提示用户登录超时
         }
 
         return res;