Skip to content

Commit

Permalink
new, update: Updated method register of void and controller and service
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladik-gif committed Oct 9, 2024
1 parent fb04114 commit 265d5e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 265d5e3

Please sign in to comment.