Skip to content

Allow super admin to login even when email login is disabled #1655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,23 @@ protected Mono<AuthUser> authenticate(String authId, @Deprecated String source,
})
.flatMap(findAuthConfig -> {
context.setAuthConfig(findAuthConfig.authConfig());
// Check if email/password is superadmin before checking EMAIL provider enable
if (findAuthConfig.authConfig().getSource().equals("EMAIL")) {
if(StringUtils.isBlank(context.getOrgId())) {
if (StringUtils.isBlank(context.getOrgId())) {
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
}
// --- Superadmin check start ---
if (context instanceof FormAuthRequestContext formContext) {
String email = formContext.getLoginId();
String password = formContext.getPassword();
String superAdminEmail = commonConfig.getSuperAdmin().getUserName();
String superAdminPassword = commonConfig.getSuperAdmin().getPassword();
if (StringUtils.equalsIgnoreCase(email, superAdminEmail) && StringUtils.equals(password, superAdminPassword)) {
// Allow superadmin login even if EMAIL provider is disabled
return Mono.just(findAuthConfig);
}
}
// --- Superadmin check end ---
if(!findAuthConfig.authConfig().getEnable()) {
return Mono.error(new BizException(EMAIL_PROVIDER_DISABLED, "EMAIL_PROVIDER_DISABLED"));
}
Expand Down
Loading