Skip to content

Commit e006db8

Browse files
committed
feat: implement password reset functionality with expiration handling and logging
1 parent c588e49 commit e006db8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

backend/src/main/java/com/park/utmstack/service/UserService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ public void completePasswordReset(String newPassword, String key) {
8888

8989
if (userOptional.isEmpty()) {
9090
log.info("{}: No user found with reset key", ctx);
91-
throw new CurrentUserLoginNotFoundException("No user found with reset key");
91+
throw new CurrentUserLoginNotFoundException(
92+
"The password reset link is invalid or no longer exists. Please request a new password reset."
93+
);
9294
}
9395

9496
User user = userOptional.get();
9597
Instant resetDeadline = Instant.now().minusSeconds(86400);
9698

9799
if (!user.getResetDate().isAfter(resetDeadline)) {
98100
log.error("{}: Reset key expired for user: {}", ctx, user.getLogin());
99-
throw new ResetKeyExpiredException(String.format("Reset key expired for user: %s", user.getLogin()));
101+
throw new ResetKeyExpiredException(
102+
"The password reset link has expired. Password reset links are valid for 24 hours. Please request a new one."
103+
);
100104
}
101105

102106
user.setPassword(passwordEncoder.encode(newPassword));

0 commit comments

Comments
 (0)