mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2026-08-11 13:51:01 +00:00
update 优化NotLoginException处理,提供更详细的错误信息
This commit is contained in:
+12
-2
@@ -44,8 +44,18 @@ public class SaTokenExceptionHandler {
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||
String msg = switch (e.getType()) {
|
||||
case NotLoginException.NOT_TOKEN -> "未检测到登录信息,请重新登录";
|
||||
case NotLoginException.INVALID_TOKEN -> "登录凭证无效,请重新登录";
|
||||
case NotLoginException.TOKEN_TIMEOUT -> "登录已过期,请重新登录";
|
||||
case NotLoginException.BE_REPLACED -> "当前账号已在其他设备登录,您已被强制下线";
|
||||
case NotLoginException.KICK_OUT -> "账号已被管理员强制下线";
|
||||
case NotLoginException.TOKEN_FREEZE -> "账号已被冻结,请联系管理员处理";
|
||||
case NotLoginException.NO_PREFIX -> "登录格式异常,请重新登录";
|
||||
default -> "登录状态异常,请重新登录";
|
||||
};
|
||||
log.error("请求地址'{}',{}", requestURI, msg);
|
||||
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,8 +24,6 @@ import java.util.List;
|
||||
@TableName("sys_menu")
|
||||
public class SysMenu extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 6967394714839655267L;
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user