From 265d5e321b068ea423e1152840407b68d155663e Mon Sep 17 00:00:00 2001 From: Vladik-gif Date: Wed, 9 Oct 2024 12:25:23 +0300 Subject: [PATCH] new, update: Updated method register of void and controller and service --- .../controller/rest/AuthenticationController.java | 6 +++--- .../com/chat/yourway/service/AuthenticationService.java | 9 ++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/chat/yourway/controller/rest/AuthenticationController.java b/src/main/java/com/chat/yourway/controller/rest/AuthenticationController.java index ad2fae9..d52c519 100644 --- a/src/main/java/com/chat/yourway/controller/rest/AuthenticationController.java +++ b/src/main/java/com/chat/yourway/controller/rest/AuthenticationController.java @@ -53,10 +53,10 @@ public class AuthenticationController { } ) @ResponseStatus(HttpStatus.CREATED) - @PostMapping(path = REGISTER, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) - public AuthResponseDto register(@Valid @RequestBody ContactRequestDto request, + @PostMapping(path = REGISTER, consumes = APPLICATION_JSON_VALUE) + public void register(@Valid @RequestBody ContactRequestDto request, @RequestHeader(HttpHeaders.REFERER) String clientHost) { - return authService.register(request, clientHost); + authService.register(request, clientHost); } @Operation(summary = "Authorization", responses = { diff --git a/src/main/java/com/chat/yourway/service/AuthenticationService.java b/src/main/java/com/chat/yourway/service/AuthenticationService.java index 4d26ac0..c189f90 100644 --- a/src/main/java/com/chat/yourway/service/AuthenticationService.java +++ b/src/main/java/com/chat/yourway/service/AuthenticationService.java @@ -32,19 +32,14 @@ public class AuthenticationService { private final AuthenticationManager authManager; @Transactional - public AuthResponseDto register(ContactRequestDto contactRequestDto, String clientHost) { + public void register(ContactRequestDto contactRequestDto, String clientHost) { log.trace("Started registration contact email: {}", contactRequestDto.getEmail()); var contact = contactService.create(contactRequestDto); - activateAccountService.sendVerifyEmail(contact, clientHost); - - var accessToken = jwtService.generateAccessToken(contact); - var refreshToken = jwtService.generateRefreshToken(contact); - saveContactToken(contact.getEmail(), accessToken); log.info("Saved registered contact {} to repository", contact.getEmail()); - return AuthResponseDto.builder().accessToken(accessToken).refreshToken(refreshToken).build(); + activateAccountService.sendVerifyEmail(contact, clientHost); } @Transactional