|
32 | 32 | import org.lowcoder.domain.user.service.UserService; |
33 | 33 | import org.lowcoder.sdk.auth.AbstractAuthConfig; |
34 | 34 | import org.lowcoder.sdk.config.AuthProperties; |
| 35 | +import org.lowcoder.sdk.config.CommonConfig; |
| 36 | +import org.lowcoder.sdk.constants.WorkspaceMode; |
35 | 37 | import org.lowcoder.sdk.exception.BizError; |
36 | 38 | import org.lowcoder.sdk.exception.BizException; |
| 39 | +import org.lowcoder.sdk.models.HasIdAndAuditing; |
37 | 40 | import org.lowcoder.sdk.util.CookieHelper; |
38 | 41 | import org.springframework.security.core.context.ReactiveSecurityContextHolder; |
39 | 42 | import org.springframework.stereotype.Service; |
@@ -69,6 +72,7 @@ public class AuthenticationApiServiceImpl implements AuthenticationApiService { |
69 | 72 | private final OrgMemberService orgMemberService; |
70 | 73 | private final JWTUtils jwtUtils; |
71 | 74 | private final AuthProperties authProperties; |
| 75 | + private final CommonConfig commonConfig; |
72 | 76 |
|
73 | 77 | @Override |
74 | 78 | public Mono<AuthUser> authenticateByForm(String loginId, String password, String source, boolean register, String authId, String orgId) { |
@@ -238,10 +242,16 @@ public Mono<Void> onUserRegister(User user, boolean isSuperAdmin) { |
238 | 242 | } |
239 | 243 |
|
240 | 244 | protected Mono<Void> onUserLogin(String orgId, User user, String source) { |
241 | | - if (StringUtils.isEmpty(orgId)) { |
242 | | - return Mono.empty(); |
| 245 | + Mono<String> orgMono; |
| 246 | + if(commonConfig.getWorkspace().getMode() == WorkspaceMode.ENTERPRISE) { |
| 247 | + orgMono = organizationService.getOrganizationInEnterpriseMode().map(HasIdAndAuditing::getId); |
| 248 | + } else { |
| 249 | + if (StringUtils.isEmpty(orgId)) { |
| 250 | + return Mono.empty(); |
| 251 | + } |
| 252 | + orgMono = Mono.just(orgId); |
243 | 253 | } |
244 | | - return orgApiService.tryAddUserToOrgAndSwitchOrg(orgId, user.getId()).then(); |
| 254 | + return orgMono.flatMap(orgId2 -> orgApiService.tryAddUserToOrgAndSwitchOrg(orgId2, user.getId())).then(); |
245 | 255 | } |
246 | 256 |
|
247 | 257 | @Override |
|
0 commit comments