From 459c2bb846c6a3cf6039ae515d549a6a0bef2a4a Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 5 Nov 2024 18:45:17 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=86=85=E4=B8=BB=E5=8A=A8=E5=88=87=E6=8D=A2=E6=88=90=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=94=A8=E6=88=B7=E4=B8=8A=E4=B8=8B=E6=96=87=E6=97=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=AE=BE=E7=BD=AEtoken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1283418883588097]代码内主动切换成系统用户上下文时没有设置token http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1283418883588097 --- .../asynchronization/threadlocal/UserContext.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/neatlogic/framework/asynchronization/threadlocal/UserContext.java b/src/main/java/neatlogic/framework/asynchronization/threadlocal/UserContext.java index 67c687c8b..b7c925666 100644 --- a/src/main/java/neatlogic/framework/asynchronization/threadlocal/UserContext.java +++ b/src/main/java/neatlogic/framework/asynchronization/threadlocal/UserContext.java @@ -23,6 +23,7 @@ import neatlogic.framework.dto.AuthenticationInfoVo; import neatlogic.framework.dto.JwtVo; import neatlogic.framework.dto.UserVo; import neatlogic.framework.exception.user.NoUserException; +import neatlogic.framework.filter.core.LoginAuthHandlerBase; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -102,7 +103,15 @@ public class UserContext implements Serializable { context.setUserUuid(userVo.getUuid()); context.setUserName(userVo.getUserName()); context.setTenant(userVo.getTenant()); - context.setToken(StringUtils.isBlank(userVo.getAuthorization()) ? userVo.getCookieAuthorization() : userVo.getAuthorization()); + String token = StringUtils.isBlank(userVo.getAuthorization()) ? userVo.getCookieAuthorization() : userVo.getAuthorization(); + if (StringUtils.isBlank(token)) { + try { + token = "GZIP_" + LoginAuthHandlerBase.buildJwt(userVo).getCc(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + context.setToken(token); context.setIsSuperAdmin(userVo.getIsSuperAdmin()); context.setRequest(request); context.setResponse(response); -- Gitee