fix(工作空间权限): 修复修改用户的last_workspace_id没有级联变更last_project_id的问题

--bug=1013629 --user=刘瑞斌 【通用功能】调用接口切换用户工作空间后,用户访问前端看到的还是之前工作空间项目的内容 https://www.tapd.cn/55049933/s/1167261
This commit is contained in:
CaptainB 2022-05-28 09:47:45 +08:00 committed by 刘瑞斌
parent cef008c865
commit 54b868bf6b
1 changed files with 12 additions and 0 deletions

View File

@ -391,6 +391,18 @@ public class UserService {
}
user.setPassword(null);
user.setUpdateTime(System.currentTimeMillis());
// 变更前
User userFromDB = userMapper.selectByPrimaryKey(user.getId());
// last workspace id 变了
if (!StringUtils.equals(user.getLastWorkspaceId(), userFromDB.getLastWorkspaceId())) {
List<Project> projects = getProjectListByWsAndUserId(user.getLastWorkspaceId());
if (projects.size() > 0) {
user.setLastProjectId(projects.get(0).getId());
} else {
user.setLastProjectId("");
}
}
// 执行变更
userMapper.updateByPrimaryKeySelective(user);
if (StringUtils.equals(user.getStatus(), UserStatus.DISABLED)) {
SessionUtils.kickOutUser(user.getId());