fix 修复 session 多账号共用覆盖问题 改为 tokenSession 独立存储

2.X
疯狂的狮子Li 1 year ago
parent 8002888224
commit eb671c1412

@ -57,7 +57,7 @@ public class LoginHelper {
model.setExtra(TENANT_KEY, loginUser.getTenantId()) model.setExtra(TENANT_KEY, loginUser.getTenantId())
.setExtra(USER_KEY, loginUser.getUserId()) .setExtra(USER_KEY, loginUser.getUserId())
.setExtra(DEPT_KEY, loginUser.getDeptId())); .setExtra(DEPT_KEY, loginUser.getDeptId()));
StpUtil.getSession().set(LOGIN_USER_KEY, loginUser); StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser);
} }
/** /**
@ -65,7 +65,7 @@ public class LoginHelper {
*/ */
public static LoginUser getLoginUser() { public static LoginUser getLoginUser() {
return (LoginUser) getStorageIfAbsentSet(LOGIN_USER_KEY, () -> { return (LoginUser) getStorageIfAbsentSet(LOGIN_USER_KEY, () -> {
SaSession session = StpUtil.getSession(); SaSession session = StpUtil.getTokenSession();
if (ObjectUtil.isNull(session)) { if (ObjectUtil.isNull(session)) {
return null; return null;
} }
@ -77,8 +77,7 @@ public class LoginHelper {
* token * token
*/ */
public static LoginUser getLoginUser(String token) { public static LoginUser getLoginUser(String token) {
Object loginId = StpUtil.getLoginIdByToken(token); SaSession session = StpUtil.getTokenSessionByToken(token);
SaSession session = StpUtil.getSessionByLoginId(loginId);
if (ObjectUtil.isNull(session)) { if (ObjectUtil.isNull(session)) {
return null; return null;
} }

Loading…
Cancel
Save