Skip to content

Commit 0b801fb

Browse files
committed
Allow super admin to login even when email login is disabled
1 parent 8f5368b commit 0b801fb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/service/AuthenticationApiServiceImpl.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,23 @@ protected Mono<AuthUser> authenticate(String authId, @Deprecated String source,
9898
})
9999
.flatMap(findAuthConfig -> {
100100
context.setAuthConfig(findAuthConfig.authConfig());
101+
// Check if email/password is superadmin before checking EMAIL provider enable
101102
if (findAuthConfig.authConfig().getSource().equals("EMAIL")) {
102-
if(StringUtils.isBlank(context.getOrgId())) {
103+
if (StringUtils.isBlank(context.getOrgId())) {
103104
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
104105
}
106+
// --- Superadmin check start ---
107+
if (context instanceof FormAuthRequestContext formContext) {
108+
String email = formContext.getLoginId();
109+
String password = formContext.getPassword();
110+
String superAdminEmail = commonConfig.getSuperAdmin().getUserName();
111+
String superAdminPassword = commonConfig.getSuperAdmin().getPassword();
112+
if (StringUtils.equalsIgnoreCase(email, superAdminEmail) && StringUtils.equals(password, superAdminPassword)) {
113+
// Allow superadmin login even if EMAIL provider is disabled
114+
return Mono.just(findAuthConfig);
115+
}
116+
}
117+
// --- Superadmin check end ---
105118
if(!findAuthConfig.authConfig().getEnable()) {
106119
return Mono.error(new BizException(EMAIL_PROVIDER_DISABLED, "EMAIL_PROVIDER_DISABLED"));
107120
}

0 commit comments

Comments
 (0)