mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-21 16:32:12 +00:00
Fix Random Password not generated when Email Config is present (#11701)
This commit is contained in:
parent
ddbc7fe14d
commit
3050363faa
@ -80,7 +80,7 @@ public final class UserUtil {
|
||||
if (providerType.equals(SSOAuthMechanism.SsoServiceType.BASIC.value())) {
|
||||
if (originalUser.getAuthenticationMechanism() == null
|
||||
|| originalUser.getAuthenticationMechanism().equals(new AuthenticationMechanism())) {
|
||||
updateUserWithHashedPwd(updatedUser, ADMIN_USER_NAME);
|
||||
updateUserWithHashedPwd(updatedUser, getPassword());
|
||||
EmailUtil.sendInviteMailToAdmin(updatedUser, ADMIN_USER_NAME);
|
||||
}
|
||||
} else {
|
||||
@ -96,7 +96,7 @@ public final class UserUtil {
|
||||
updatedUser = user(username, domain, username).withIsAdmin(isAdmin).withIsEmailVerified(true);
|
||||
// Update Auth Mechanism if not present, and send mail to the user
|
||||
if (providerType.equals(SSOAuthMechanism.SsoServiceType.BASIC.value())) {
|
||||
updateUserWithHashedPwd(updatedUser, ADMIN_USER_NAME);
|
||||
updateUserWithHashedPwd(updatedUser, getPassword());
|
||||
EmailUtil.sendInviteMailToAdmin(updatedUser, ADMIN_USER_NAME);
|
||||
}
|
||||
}
|
||||
@ -105,6 +105,16 @@ public final class UserUtil {
|
||||
addOrUpdateUser(updatedUser);
|
||||
}
|
||||
|
||||
private static String getPassword() {
|
||||
try {
|
||||
EmailUtil.getInstance().testConnection();
|
||||
return PasswordUtil.generateRandomPassword();
|
||||
} catch (Exception ex) {
|
||||
LOG.info("Password set to Default.");
|
||||
}
|
||||
return ADMIN_USER_NAME;
|
||||
}
|
||||
|
||||
public static void updateUserWithHashedPwd(User user, String pwd) {
|
||||
String hashedPwd = BCrypt.withDefaults().hashToString(12, pwd.toCharArray());
|
||||
user.setAuthenticationMechanism(
|
||||
|
Loading…
x
Reference in New Issue
Block a user