Skip to content

Commit 8ae6b32

Browse files
authored
Merge pull request #1267 from lowcoder-org/fix/disabled_email
forbid email login that is disabled
2 parents 0d9424e + 7786f32 commit 8ae6b32

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/exception/BizError.java

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public enum BizError {
102102
JWT_NOT_FIND(400, 5619),
103103
ID_NOT_EXIST(500, 5620),
104104
DUPLICATE_AUTH_CONFIG_ADDITION(400, 5621),
105+
EMAIL_PROVIDER_DISABLED(403, 5622),
105106

106107

107108
// asset related, code range 5700 - 5799

server/api-service/lowcoder-sdk/src/main/resources/locale_en.properties

+1
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,4 @@ ORG_DELETED_FOR_ENTERPRISE_MODE=Provided enterpriseOrgId workspace has been dele
281281
DISABLE_AUTH_CONFIG_FORBIDDEN=Can not disable current administrator''s last identity provider.
282282
USER_NOT_EXIST=User not exist.
283283
DUPLICATE_AUTH_CONFIG_ADDITION=Provider auth type already added to organization
284+
EMAIL_PROVIDER_DISABLED=Email provider is disabled.

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ protected Mono<AuthUser> authenticate(String authId, @Deprecated String source,
8888
log.warn("source is deprecated and will be removed in the future, please use authId instead. {}", source);
8989
return authenticationService.findAuthConfigBySource(context.getOrgId(), source);
9090
})
91-
.doOnNext(findAuthConfig -> {
91+
.flatMap(findAuthConfig -> {
9292
context.setAuthConfig(findAuthConfig.authConfig());
9393
if (findAuthConfig.authConfig().getSource().equals("EMAIL")) {
9494
if(StringUtils.isBlank(context.getOrgId())) {
9595
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
9696
}
97+
if(!findAuthConfig.authConfig().getEnable()) {
98+
return Mono.error(new BizException(EMAIL_PROVIDER_DISABLED, "EMAIL_PROVIDER_DISABLED"));
99+
}
97100
} else {
98101
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
99102
}
103+
return Mono.just(findAuthConfig);
100104
})
101105
.then(authRequestFactory.build(context))
102106
.flatMap(authRequest -> authRequest.auth(context))

0 commit comments

Comments
 (0)