Skip to content

Commit db0357e

Browse files
Thomasrludomikula
Thomasr
authored andcommitted
Fixed adding superadmin to created workspace realtime
1 parent 54c9723 commit db0357e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/organization/service/OrganizationServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ private Mono<Organization> onOrgCreated(String userId, Organization newOrg, bool
153153
return groupService.createAllUserGroup(newOrg.getId())
154154
.then(groupService.createDevGroup(newOrg.getId()))
155155
.then(setOrgAdmin(userId, newOrg, isSuperAdmin))
156-
.then(userRepository.findAll().filter(User::getSuperAdmin).last().map(superAdminUser -> {
156+
.then(userRepository.findBySuperAdminIsTrue().flatMap(superAdminUser -> {
157157
if(!userId.equals(superAdminUser.getId())) {
158158
return setOrgSuperAdmin(superAdminUser.getId(), newOrg);
159159
}
160160
return Mono.empty();
161-
}))
161+
}).then())
162162
.thenReturn(newOrg);
163163
}
164164

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/user/repository/UserRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
public interface UserRepository extends ReactiveMongoRepository<User, String> {
1414

1515
Flux<User> findByIdIn(Collection<String> ids);
16+
Mono<User> findBySuperAdminIsTrue();
1617

1718
Mono<User> findByConnections_SourceAndConnections_RawId(String source, String rawId);
1819

0 commit comments

Comments
 (0)