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 @@ -28,6 +28,8 @@ public class AuthenticationService implements IAuthenticationService{
public static String baseUrl;
private static final String EMAIL_REGEX = "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$";
private static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL_REGEX);
@Value("${email.verification.url}")
private String emailVerificationUrl;

BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
IUserRepository userRepository;
Expand Down Expand Up @@ -60,14 +62,25 @@ public User register(String username, String email, String password) {
String hashedPassword = bCryptPasswordEncoder.encode(password);
User newUser = new User(username, email, hashedPassword);
User storedUser = this.userRepository.save(newUser);

EmailVerificationToken emailVerificationToken = new EmailVerificationToken(storedUser);
this.emailVerificationTokenRepository.save(emailVerificationToken);
String eMailText = "Your email verification code: " + emailVerificationToken.getToken();

String eMailText =
"Only one step left to start using Floaty! \n\n" +
"Enter the code in the verification page of the app: \n\n" +
emailVerificationToken.getToken() + "\n\n\n\n" +
"If you closed the app, you can also click on the following link to verify your email: \n\n" +
emailVerificationUrl + "\n\n\n\n" +
"Best, Floaty Team";

String eMailSubject = "Floaty Email Verification";
emailService.sendSimpleEmail(storedUser.getEmail(), eMailSubject, eMailText);

return storedUser;
}


private void validateEmailNotTaken(String email) throws EMailAlreadyUsedException {
if (this.userRepository.existsByEmail(email)) {
throw new EMailAlreadyUsedException();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application-docker-compose.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ spring.mail.properties.mail.debug=false
#spring.mail.port=587
#spring.mail.username=apikey
#spring.mail.password=${SENDGRID_API_KEY}
email.verification.url=https://app.floatyfly.com/#/email-validation
3 changes: 2 additions & 1 deletion src/main/resources/application-local-h2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ spring.mail.password= # No authentication
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.debug=false
spring.mail.properties.mail.debug=false
email.verification.url=http://localhost:8200/#/email-validation
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ server.address=0.0.0.0

spring.mvc.pathmatch.matching-strategy=ant_path_matcher
server.error.include-stacktrace=never

Loading