Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

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 @@ -65,6 +65,11 @@ public interface UserPasswordResetManager {
"Password for SMTP server for sending emails for resetting password for ACS users",
false, ConfigKey.Scope.Global);

ConfigKey<String> UserPasswordResetDomainURL = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED,
String.class, "user.password.reset.mail.domain.url", null,
"Domain URL for reset password links sent to the user via email", true,
ConfigKey.Scope.Global);

void setResetTokenAndSend(UserAccount userAccount);

boolean validateAndResetPassword(UserAccount user, String token, String password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.util.Set;
import java.util.UUID;

import static org.apache.cloudstack.config.ApiServiceConfiguration.ManagementServerAddresses;
import static org.apache.cloudstack.resourcedetail.UserDetailVO.PasswordResetToken;
import static org.apache.cloudstack.resourcedetail.UserDetailVO.PasswordResetTokenExpiryDate;

Expand All @@ -69,7 +68,7 @@ public class UserPasswordResetManagerImpl extends ManagerBase implements UserPas
new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, String.class,
"user.password.reset.mail.template", "Hello {{username}}!\n" +
"You have requested to reset your password. Please click the following link to reset your password:\n" +
"http://{{{resetLink}}}\n" +
"{{{domainUrl}}}{{{resetLink}}}\n" +
"If you did not request a password reset, please ignore this email.\n" +
"\n" +
"Regards,\n" +
Expand All @@ -95,6 +94,7 @@ public ConfigKey<?>[] getConfigKeys() {
UserPasswordResetSMTPUseAuth,
UserPasswordResetSMTPUsername,
UserPasswordResetSMTPPassword,
UserPasswordResetDomainURL,
PasswordResetMailTemplate
};
}
Expand Down Expand Up @@ -173,9 +173,10 @@ public void setResetTokenAndSend(UserAccount userAccount) {
final String email = userAccount.getEmail();
final String username = userAccount.getUsername();
final String subject = "Password Reset Request";
final String domainUrl = UserPasswordResetDomainURL.value();

String resetLink = String.format("%s/client/#/user/resetPassword?username=%s&token=%s",
ManagementServerAddresses.value().split(",")[0], username, resetToken);
String resetLink = String.format("/client/#/user/resetPassword?username=%s&token=%s",
username, resetToken);
String content = getMessageBody(userAccount, resetToken, resetLink);

SMTPMailProperties mailProperties = new SMTPMailProperties();
Expand Down
Loading