Commit 52816adc authored by tangtuo's avatar tangtuo

修改登录失败的异常处理

parent 45103940
......@@ -56,5 +56,10 @@
<option name="name" value="local private nexus" />
<option name="url" value="http://maven.citydo.com.cn/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://maven.aliyun.com/repository/public" />
</remote-repository>
</component>
</project>
\ No newline at end of file
package com.fzm.common.exception.handler;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.*;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpStatus;
......@@ -46,10 +46,11 @@ public class GlobalExceptionHandler {
return ResponseModel.fail(exception);
}
@ExceptionHandler(value = NotLoginException.class)
public ResponseModel<String> handlerNotLoginException(NotLoginException exception) {
@ExceptionHandler(value = SaTokenException.class)
public ResponseModel<String> handlerNotLoginException(SaTokenException exception) {
log.error(exception.getMessage(), exception);
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
if (exception instanceof NotLoginException) {
if (exception.getMessage().contains("token已被顶下线")) {
// 获取已过期的token
String expireToken = StpUtil.getTokenValue();
......@@ -61,11 +62,17 @@ public class GlobalExceptionHandler {
String format = DateUtil.format(createTime, "yyyy-MM-dd HH:mm:ss");
return ResponseModel.fail(ResultCode.UNAUTHORIZED,
String.format("您的账号于 %s 登录另外一台设备,如非您本人所为,请立即修改密码", format));
} else {
return ResponseModel.fail(ResultCode.UNAUTHORIZED, exception.getMessage());
}
} else if (exception instanceof NotPermissionException || exception instanceof NotRoleException || exception instanceof StopMatchException) {
return ResponseModel.fail(ResultCode.FORBIDDEN, ResultCode.FORBIDDEN.getMessage());
} else {
return ResponseModel.fail(exception);
}
}
@ExceptionHandler(value = {MethodArgumentNotValidException.class})
public ResponseModel<String> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
log.error(e.getMessage(), e);
......
......@@ -8,7 +8,7 @@
u.nickname,
u.auth_type,
u.create_date AS registerDate,
(select count(0) from tb_nft n where u.id = n.user_id) as publishCount
(select count(0) from tb_nft n where u.id = n.user_id and n.nft_hash != '') as publishCount
FROM tb_user u
where 1=1
<if test="telephone != null and telephone != ''">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment