From 5062aa12dae1c725d415205e360a9b59a23f9a6e Mon Sep 17 00:00:00 2001 From: gaopeng <50567478+gaopeng666@users.noreply.github.com> Date: Thu, 7 Sep 2023 19:56:38 +0800 Subject: [PATCH] [Fix-14811][fix] Fix when using Casdoor SSO, ldap, OAuth2 to log in, the tenant problem of not specifying the currently logged in user (#14812) --- .../dolphinscheduler/api/controller/LoginController.java | 3 ++- .../dolphinscheduler/api/service/impl/UsersServiceImpl.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java index f535e48776..33e0e519b2 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java @@ -31,6 +31,7 @@ import org.apache.dolphinscheduler.api.service.SessionService; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; +import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.OkHttpUtils; import org.apache.dolphinscheduler.dao.entity.User; @@ -241,7 +242,7 @@ public class LoginController extends BaseController { String username = JSONUtils.getNodeString(userInfoJsonStr, "login"); User user = usersService.getUserByUserName(username); if (user == null) { - user = usersService.createUser(username, null, null, 0, null, null, 1); + user = usersService.createUser(UserType.GENERAL_USER, username, null); } String sessionId = sessionService.createSession(user, null); if (sessionId == null) { diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java index 27f8e5f8ef..f75a8ab8db 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java @@ -224,7 +224,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { } /*** - * create User for ldap and sso login + * create User for ldap、Casdoor SSO and OAuth2.0 login */ @Override @Transactional @@ -238,6 +238,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService { user.setUserType(userType); user.setCreateTime(now); user.setUpdateTime(now); + user.setTenantId(-1); user.setQueue(""); user.setState(Flag.YES.getCode());