Skip to content

Commit

Permalink
task: updated active contact after authentication - version beta for …
Browse files Browse the repository at this point in the history
…task
  • Loading branch information
Vladik-gif committed Oct 25, 2024
1 parent 0fee8f9 commit 8f934f3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public AuthResponseDto refreshToken(HttpServletRequest request) {
content = @Content(schema = @Schema(implementation = ApiErrorResponseDto.class)))
})
@PostMapping(path = ACTIVATE, consumes = APPLICATION_JSON_VALUE)
public void activateAccount(@RequestParam(name = "Email token") UUID token) {
authService.activateAccount(token);
public void activateAccount() {
authService.activateAccount();
}

@Operation(summary = "Resend email", responses = {
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/com/chat/yourway/service/ActivateAccountService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,13 @@ public class ActivateAccountService {
private final ContactService contactService;

@Transactional
public void activateAccount(UUID token) {
log.trace("Started activateAccount by email token");
public void activateAccount() {
log.trace("Started activateAccount by email");

EmailToken emailToken = emailTokenRepository.findById(token)
.orElseThrow(() -> {
log.warn("Current email token does not exist in repository");
return new EmailTokenNotFoundException();
});

Contact contact = emailToken.getContact();
final var contact = contactService.getCurrentContact();
contact.setActive(true);
contactService.save(contact);

emailTokenRepository.delete(emailToken);

log.info("Account is activate for contact email [{}]", contact.getEmail());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public AuthResponseDto refreshToken(HttpServletRequest request) {
return AuthResponseDto.builder().accessToken(accessToken).refreshToken(refreshToken).build();
}

public void activateAccount(UUID token) {
activateAccountService.activateAccount(token);
public void activateAccount() {
activateAccountService.activateAccount();
}

public void logout(HttpServletRequest request, HttpServletResponse response, Authentication auth) {
Expand Down

0 comments on commit 8f934f3

Please sign in to comment.