Skip to content

Commit f2b7d10

Browse files
dragonpooludomikula
authored andcommitted
Allow super admin to login even when email login is disabled
1 parent 5a9732c commit f2b7d10

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

Lines changed: 14 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy