mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 20:06:19 +00:00
[FIX] Fix IsEmailServiceEnabled. (#17601)
* fix isEmailServiceEnabled. * use getSmtpSettings() from emailUtil
This commit is contained in:
parent
8c9abbcae7
commit
19b5d49dc8
@ -27,6 +27,7 @@ import static org.openmetadata.service.exception.CatalogExceptionMessage.EMAIL_S
|
||||
import static org.openmetadata.service.jdbi3.UserRepository.AUTH_MECHANISM_FIELD;
|
||||
import static org.openmetadata.service.secrets.ExternalSecretsManager.NULL_SECRET_STRING;
|
||||
import static org.openmetadata.service.security.jwt.JWTTokenGenerator.getExpiryDate;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
import static org.openmetadata.service.util.UserUtil.getRoleListFromUser;
|
||||
import static org.openmetadata.service.util.UserUtil.getRolesFromAuthorizationToken;
|
||||
import static org.openmetadata.service.util.UserUtil.getUser;
|
||||
@ -191,6 +192,10 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
return user;
|
||||
}
|
||||
|
||||
private boolean isEmailServiceEnabled() {
|
||||
return getSmtpSettings().getEnableSmtpServer();
|
||||
}
|
||||
|
||||
public UserResource(
|
||||
Authorizer authorizer, Limits limits, AuthenticatorHandler authenticatorHandler) {
|
||||
super(Entity.USER, authorizer, limits);
|
||||
@ -643,7 +648,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
}
|
||||
|
||||
private void sendInviteMailToUserForBasicAuth(UriInfo uriInfo, User user, CreateUser create) {
|
||||
if (isBasicAuth() && isEmailServiceEnabled) {
|
||||
if (isBasicAuth() && isEmailServiceEnabled()) {
|
||||
try {
|
||||
authHandler.sendInviteMailToUser(
|
||||
uriInfo,
|
||||
|
@ -111,6 +111,10 @@ public class BasicAuthenticator implements AuthenticatorHandler {
|
||||
this.isSelfSignUpAvailable = config.getAuthenticationConfiguration().getEnableSelfSignup();
|
||||
}
|
||||
|
||||
private boolean isEmailServiceEnabled() {
|
||||
return getSmtpSettings().getEnableSmtpServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public User registerUser(RegistrationRequest newRegistrationRequest) {
|
||||
if (isSelfSignUpAvailable) {
|
||||
@ -173,7 +177,7 @@ public class BasicAuthenticator implements AuthenticatorHandler {
|
||||
|
||||
@Override
|
||||
public void sendEmailVerification(UriInfo uriInfo, User user) throws IOException {
|
||||
if (isEmailServiceEnabled) {
|
||||
if (isEmailServiceEnabled()) {
|
||||
UUID mailVerificationToken = UUID.randomUUID();
|
||||
EmailVerificationToken emailVerificationToken =
|
||||
TokenUtil.getEmailVerificationToken(user.getId(), mailVerificationToken);
|
||||
@ -310,7 +314,7 @@ public class BasicAuthenticator implements AuthenticatorHandler {
|
||||
loginAttemptCache.recordSuccessfulLogin(userName);
|
||||
|
||||
// in case admin updates , send email to user
|
||||
if (request.getRequestType() == USER && isEmailServiceEnabled) {
|
||||
if (request.getRequestType() == USER && isEmailServiceEnabled()) {
|
||||
// Send mail
|
||||
sendInviteMailToUser(
|
||||
uriInfo,
|
||||
|
Loading…
x
Reference in New Issue
Block a user