Skip to content

Commit 9184170

Browse files
daviftorresDavi Torressureshanaparti
authored
Remove Domain/IP from Password Reset Link to custom Global Setting (#11379)
Co-authored-by: Davi Torres <[email protected]> Co-authored-by: Suresh Kumar Anaparti <[email protected]>
1 parent 3c4f458 commit 9184170

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

server/src/main/java/org/apache/cloudstack/user/UserPasswordResetManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public interface UserPasswordResetManager {
6565
"Password for SMTP server for sending emails for resetting password for ACS users",
6666
false, ConfigKey.Scope.Global);
6767

68+
ConfigKey<String> UserPasswordResetDomainURL = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED,
69+
String.class, "user.password.reset.mail.domain.url", null,
70+
"Domain URL for reset password links sent to the user via email", true,
71+
ConfigKey.Scope.Global);
72+
6873
void setResetTokenAndSend(UserAccount userAccount);
6974

7075
boolean validateAndResetPassword(UserAccount user, String token, String password);

server/src/main/java/org/apache/cloudstack/user/UserPasswordResetManagerImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import java.util.Set;
4949
import java.util.UUID;
5050

51-
import static org.apache.cloudstack.config.ApiServiceConfiguration.ManagementServerAddresses;
5251
import static org.apache.cloudstack.resourcedetail.UserDetailVO.PasswordResetToken;
5352
import static org.apache.cloudstack.resourcedetail.UserDetailVO.PasswordResetTokenExpiryDate;
5453

@@ -69,7 +68,7 @@ public class UserPasswordResetManagerImpl extends ManagerBase implements UserPas
6968
new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, String.class,
7069
"user.password.reset.mail.template", "Hello {{username}}!\n" +
7170
"You have requested to reset your password. Please click the following link to reset your password:\n" +
72-
"http://{{{resetLink}}}\n" +
71+
"{{{domainUrl}}}{{{resetLink}}}\n" +
7372
"If you did not request a password reset, please ignore this email.\n" +
7473
"\n" +
7574
"Regards,\n" +
@@ -95,6 +94,7 @@ public ConfigKey<?>[] getConfigKeys() {
9594
UserPasswordResetSMTPUseAuth,
9695
UserPasswordResetSMTPUsername,
9796
UserPasswordResetSMTPPassword,
97+
UserPasswordResetDomainURL,
9898
PasswordResetMailTemplate
9999
};
100100
}
@@ -173,9 +173,10 @@ public void setResetTokenAndSend(UserAccount userAccount) {
173173
final String email = userAccount.getEmail();
174174
final String username = userAccount.getUsername();
175175
final String subject = "Password Reset Request";
176+
final String domainUrl = UserPasswordResetDomainURL.value();
176177

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

181182
SMTPMailProperties mailProperties = new SMTPMailProperties();

0 commit comments

Comments
 (0)