Skip to content

Commit

Permalink
Make reset and creation links into an actual anchor tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Jun 16, 2024
1 parent 47704e0 commit b32f656
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.chalmers.gamma.app.user;

import static it.chalmers.gamma.app.authentication.AccessGuard.isAdmin;
import static it.chalmers.gamma.app.authentication.AccessGuard.isNotSignedIn;

import it.chalmers.gamma.app.Facade;
import it.chalmers.gamma.app.authentication.AccessGuard;
import it.chalmers.gamma.app.common.Email;
Expand All @@ -10,16 +13,12 @@
import it.chalmers.gamma.app.user.allowlist.AllowListRepository;
import it.chalmers.gamma.app.user.domain.*;
import jakarta.transaction.Transactional;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.UUID;

import static it.chalmers.gamma.app.authentication.AccessGuard.isAdmin;
import static it.chalmers.gamma.app.authentication.AccessGuard.isNotSignedIn;

@Service
public class UserCreationFacade extends Facade {

Expand Down Expand Up @@ -132,7 +131,14 @@ public void createUserWithCode(
private void sendEmail(Cid cid, UserActivationToken userActivationToken) {
String to = cid.getValue() + "@" + MAIL_POSTFIX;
String resetUrl = baseUrl + "/register?token=" + userActivationToken.value();
String message = "Follow this link to finish up creating your account: " + resetUrl + ". \nThe link is valid for 15 minutes.";
String message =
"""
Follow this link to finish up creating your account:
<a href="%s">%s</a>
The link is valid for 15 minutes.
"""
.formatted(resetUrl, resetUrl);

this.mailService.sendMail(to, "Gamma activation url", message);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package it.chalmers.gamma.app.user.passwordreset;

import static it.chalmers.gamma.app.authentication.AccessGuard.isNotSignedIn;

import it.chalmers.gamma.app.Facade;
import it.chalmers.gamma.app.authentication.AccessGuard;
import it.chalmers.gamma.app.common.Email;
Expand All @@ -17,8 +19,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import static it.chalmers.gamma.app.authentication.AccessGuard.isNotSignedIn;

@Service
public class UserResetPasswordFacade extends Facade {

Expand Down Expand Up @@ -92,9 +92,12 @@ private void sendPasswordResetTokenMail(Email email, PasswordResetToken token) {
String resetUrl = this.baseUrl + "/forgot-password/finalize?token=" + token.value();

String message =
"A password reset have been requested for this account, if you have not requested "
+ "this mail, feel free to ignore it. \n Click here to reset password: "
+ resetUrl + ". \nThe link is valid for 15 minutes.";
"""
A password reset have been requested for this account, if you have not requested this mail, feel free to ignore it.
Click here to reset password: <a href="%s">%s</a>
The link is valid for 15 minutes.
"""
.formatted(resetUrl, resetUrl);

this.mailService.sendMail(email.value(), subject, message);
}
Expand Down

0 comments on commit b32f656

Please sign in to comment.