Skip to content

Commit ed34842

Browse files
Fix url in password reset email
1 parent e90e31d commit ed34842

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

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

51+
import static org.apache.cloudstack.config.ApiServiceConfiguration.ManagementServerAddresses;
5152
import static org.apache.cloudstack.resourcedetail.UserDetailVO.PasswordResetToken;
5253
import static org.apache.cloudstack.resourcedetail.UserDetailVO.PasswordResetTokenExpiryDate;
5354

@@ -68,7 +69,7 @@ public class UserPasswordResetManagerImpl extends ManagerBase implements UserPas
6869
new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, String.class,
6970
"user.password.reset.mail.template", "Hello {{username}}!\n" +
7071
"You have requested to reset your password. Please click the following link to reset your password:\n" +
71-
"{{{domainUrl}}}{{{resetLink}}}\n" +
72+
"{{{resetLink}}}\n" +
7273
"If you did not request a password reset, please ignore this email.\n" +
7374
"\n" +
7475
"Regards,\n" +
@@ -179,10 +180,14 @@ public void setResetTokenAndSend(UserAccount userAccount) {
179180
final String email = userAccount.getEmail();
180181
final String username = userAccount.getUsername();
181182
final String subject = "Password Reset Request";
182-
final String domainUrl = UserPasswordResetDomainURL.value();
183+
String domainUrl = UserPasswordResetDomainURL.value();
184+
if (StringUtils.isBlank(domainUrl)) {
185+
domainUrl = ManagementServerAddresses.value().split(",")[0];
186+
}
187+
domainUrl = domainUrl.replaceAll("/+$", "");
183188

184-
String resetLink = String.format("/client/#/user/resetPassword?username=%s&token=%s",
185-
username, resetToken);
189+
String resetLink = String.format("%s/client/#/user/resetPassword?username=%s&token=%s",
190+
domainUrl, username, resetToken);
186191
String content = getMessageBody(userAccount, resetToken, resetLink);
187192

188193
SMTPMailProperties mailProperties = new SMTPMailProperties();

0 commit comments

Comments
 (0)