Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem #453

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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 @@ -76,11 +76,18 @@ public void updatePasswordUsingToken(OwnRestoreDto form) {
throw new BadRequestException(ErrorMessage.PASSWORDS_DO_NOT_MATCH);
}
User user = restorePasswordEmail.getUser();
String recipientName = (user.getName() != null && !user.getName().isBlank())
? user.getName()
: (user.getFirstName() != null && !user.getFirstName().isBlank()
? user.getFirstName()
: "User");
UserStatus userStatus = restorePasswordEmail.getUser().getUserStatus();
if (isNotExpired(restorePasswordEmail.getExpiryDate())) {
updatePassword(form.getPassword(), restorePasswordEmail.getUser().getId());
emailService.sendSuccessRestorePasswordByEmail(user.getEmail(), user.getLanguage().getCode(),
user.getName(), form.getIsUbs());
emailService.sendSuccessRestorePasswordByEmail(user.getEmail(),
user.getLanguage().getCode(),
recipientName,
form.getIsUbs());
applicationEventPublisher.publishEvent(
new UpdatePasswordEvent(this, form.getPassword(), restorePasswordEmail.getUser().getId()));
user.setRestorePasswordEmail(null);
Expand Down Expand Up @@ -112,9 +119,14 @@ private void savePasswordRestorationTokenForUser(User user, String token, boolea
.expiryDate(calculateExpirationDate(tokenExpirationTimeInHours))
.build();
restorePasswordEmailRepo.save(restorePasswordEmail);
String recipientName = (user.getFirstName() != null && !user.getFirstName().isBlank())
? user.getFirstName()
: (user.getName() != null && !user.getName().isBlank()
? user.getName()
: "User");
Comment on lines +122 to +126
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Align the name priority logic with the previous implementation.

The name determination logic here prioritizes firstName over name, while the previous implementation does the opposite. This inconsistency could lead to different name selections in different scenarios.

-        String recipientName = (user.getFirstName() != null && !user.getFirstName().isBlank())
-            ? user.getFirstName()
-            : (user.getName() != null && !user.getName().isBlank()
-                ? user.getName()
-                : "User");
+        String recipientName = determineRecipientName(user);

Committable suggestion skipped: line range outside the PR's diff.

emailService.sendRestoreEmail(
user.getId(),
user.getFirstName(),
recipientName,
user.getEmail(),
token,
user.getLanguage().getCode(),
Expand Down
Loading