From 31dd3ea516e64f7f156a1550b790152a0232b8c6 Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 5 Jul 2024 18:49:39 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BD=BF=E7=94=A8=E5=A4=B1=E6=95=88=20?= =?UTF-8?q?token=20=E8=AF=B7=E6=B1=82=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=20401=20=E6=95=B0=E6=8D=AE=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/rymcu/forest/auth/JwtFilter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rymcu/forest/auth/JwtFilter.java b/src/main/java/com/rymcu/forest/auth/JwtFilter.java index b2fb341..e7c2835 100644 --- a/src/main/java/com/rymcu/forest/auth/JwtFilter.java +++ b/src/main/java/com/rymcu/forest/auth/JwtFilter.java @@ -1,7 +1,10 @@ package com.rymcu.forest.auth; import com.alibaba.fastjson2.JSONObject; +import com.rymcu.forest.core.result.GlobalResult; import com.rymcu.forest.core.result.GlobalResultGenerator; +import com.rymcu.forest.core.result.ResultCode; +import com.rymcu.forest.util.ErrorCode; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureException; @@ -126,7 +129,8 @@ public class JwtFilter extends BasicHttpAuthenticationFilter { HttpServletResponse httpServletResponse = (HttpServletResponse) response; httpServletResponse.setContentType("application/json"); httpServletResponse.setCharacterEncoding("UTF-8"); - httpServletResponse.getOutputStream().write(JSONObject.toJSONString(GlobalResultGenerator.genErrorResult("未登录或已登录超时,请重新登录")).getBytes()); + httpServletResponse.getOutputStream().write(JSONObject.toJSONString(new GlobalResult<>(ResultCode.UNAUTHENTICATED)).getBytes()); + httpServletResponse.getOutputStream().flush(); } catch (IOException e) { // 错误日志 log.error(e.getMessage());