|
|
@@ -8,6 +8,7 @@ import cn.hutool.http.HttpStatus;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.springframework.core.annotation.Order;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
|
|
|
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
* @author Lion Li
|
|
|
*/
|
|
|
@Slf4j
|
|
|
+@Order(-1) // 设置更高优先级,确保在GlobalExceptionHandler之前执行
|
|
|
@RestControllerAdvice
|
|
|
public class SaTokenExceptionHandler {
|
|
|
|
|
|
@@ -46,6 +48,11 @@ public class SaTokenExceptionHandler {
|
|
|
@ExceptionHandler(NotLoginException.class)
|
|
|
public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
|
|
String requestURI = request.getRequestURI();
|
|
|
+ // 检查是否是token被冻结的情况
|
|
|
+ if (e.getMessage() != null && e.getMessage().contains("已被冻结")) {
|
|
|
+ log.error("请求地址'{}',Token被冻结'{}',请重新登录", requestURI, e.getMessage());
|
|
|
+ return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "账号已在其他地点登录或被管理员强制下线,请重新登录");
|
|
|
+ }
|
|
|
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
|
|
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
|
|
}
|