feat: 新增JWT刷新模式和JWT工具类解耦优化

This commit is contained in:
haoxr
2024-11-14 18:32:08 +08:00
parent c7621f90cb
commit 88ccaff448
8 changed files with 47 additions and 104 deletions

View File

@@ -36,7 +36,10 @@ public enum ResultCode implements IResultCode, Serializable {
VERIFY_CODE_ERROR("A0214", "验证码错误"),
TOKEN_INVALID("A0230", "token无效或已过期"),
TOKEN_ACCESS_FORBIDDEN("A0231", "token已被禁止访问"),
REFRESH_TOKEN_INVALID("A0231", "刷新token无效或已过期"),
TOKEN_ACCESS_FORBIDDEN("A0232", "token已被禁止访问"),
AUTHORIZED_ERROR("A0300", "访问权限异常"),
ACCESS_UNAUTHORIZED("A0301", "访问未授权"),

View File

@@ -30,7 +30,7 @@ public class ResponseUtils {
public static void writeErrMsg(HttpServletResponse response, ResultCode resultCode) {
// 根据不同的结果码设置HTTP状态
int status = switch (resultCode) {
case ACCESS_UNAUTHORIZED, TOKEN_INVALID -> HttpStatus.UNAUTHORIZED.value();
case ACCESS_UNAUTHORIZED, TOKEN_INVALID,REFRESH_TOKEN_INVALID -> HttpStatus.UNAUTHORIZED.value();
case TOKEN_ACCESS_FORBIDDEN -> HttpStatus.FORBIDDEN.value();
default -> HttpStatus.BAD_REQUEST.value();
};