Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f2b7d10

Browse files
Thomasrludomikula
Thomasr
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)

AltStyle によって変換されたページ (->オリジナル) /