mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【auth】更新重新创建loginUser的逻辑
parent
03b8b747d8
commit
aaae9fbc94
|
@ -65,7 +65,6 @@ import cn.stylefeng.roses.kernel.jwt.api.exception.JwtException;
|
||||||
import cn.stylefeng.roses.kernel.jwt.api.exception.enums.JwtExceptionEnum;
|
import cn.stylefeng.roses.kernel.jwt.api.exception.enums.JwtExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.jwt.api.pojo.config.JwtConfig;
|
import cn.stylefeng.roses.kernel.jwt.api.pojo.config.JwtConfig;
|
||||||
import cn.stylefeng.roses.kernel.log.api.LoginLogServiceApi;
|
import cn.stylefeng.roses.kernel.log.api.LoginLogServiceApi;
|
||||||
import cn.stylefeng.roses.kernel.message.api.expander.WebSocketConfigExpander;
|
|
||||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||||
import cn.stylefeng.roses.kernel.rule.tenant.RequestTenantCodeHolder;
|
import cn.stylefeng.roses.kernel.rule.tenant.RequestTenantCodeHolder;
|
||||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||||
|
@ -85,8 +84,6 @@ import io.jsonwebtoken.Claims;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum.AUTH_EXPIRED_ERROR;
|
import static cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum.AUTH_EXPIRED_ERROR;
|
||||||
import static cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum.TOKEN_PARSE_ERROR;
|
import static cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum.TOKEN_PARSE_ERROR;
|
||||||
|
@ -285,7 +282,7 @@ public class AuthServiceImpl implements AuthServiceApi {
|
||||||
// 获取用户租户信息
|
// 获取用户租户信息
|
||||||
String tenantCode = defaultJwtPayload.getTenantCode();
|
String tenantCode = defaultJwtPayload.getTenantCode();
|
||||||
|
|
||||||
UserLoginInfoDTO userLoginInfo;
|
LoginUser loginUser;
|
||||||
try {
|
try {
|
||||||
// 如果有特定租户则进行切换操作
|
// 如果有特定租户则进行切换操作
|
||||||
if (StrUtil.isNotEmpty(tenantCode) && !DatasourceContainerConstants.MASTER_DATASOURCE_NAME.equals(tenantCode)) {
|
if (StrUtil.isNotEmpty(tenantCode) && !DatasourceContainerConstants.MASTER_DATASOURCE_NAME.equals(tenantCode)) {
|
||||||
|
@ -293,16 +290,10 @@ public class AuthServiceImpl implements AuthServiceApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
userLoginInfo = userServiceApi.getUserLoginInfo(account);
|
UserValidateDTO userValidateDTO = sysUserServiceApi.getUserLoginValidateDTO(account);
|
||||||
LoginUser loginUser = userLoginInfo.getLoginUser();
|
|
||||||
loginUser.setTenantCode(tenantCode);
|
|
||||||
|
|
||||||
// 设置websocket url
|
// 创建登录用户
|
||||||
String webSocketWsUrl = WebSocketConfigExpander.getWebSocketWsUrl();
|
loginUser = new LoginUser(userValidateDTO.getUserId(), token);
|
||||||
Map<String, String> params = new HashMap<>(1);
|
|
||||||
params.put("token", token);
|
|
||||||
webSocketWsUrl = StrUtil.format(webSocketWsUrl, params);
|
|
||||||
loginUser.setWsUrl(webSocketWsUrl);
|
|
||||||
|
|
||||||
// 创建用户会话信息
|
// 创建用户会话信息
|
||||||
sessionManagerApi.updateSession(token, loginUser);
|
sessionManagerApi.updateSession(token, loginUser);
|
||||||
|
@ -311,7 +302,7 @@ public class AuthServiceImpl implements AuthServiceApi {
|
||||||
CurrentDataSourceContext.clearDataSourceName();
|
CurrentDataSourceContext.clearDataSourceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return userLoginInfo.getLoginUser();
|
return loginUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue