4848import java .util .Set ;
4949import java .util .UUID ;
5050
51+ import static org .apache .cloudstack .config .ApiServiceConfiguration .ManagementServerAddresses ;
5152import static org .apache .cloudstack .resourcedetail .UserDetailVO .PasswordResetToken ;
5253import 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