@PostMapping(value = {"/auth"}, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> authenticate(@RequestBody AuthenticationRequest authenticationRequest, HttpServletResponse response) {
Authentication authentication = authenticationService.authenticate(authenticationRequest);
if(authentication != null && authentication.isAuthenticated()) {
JwtTokens tokens = jwtTokenService.createTokens(authentication);
return ResponseEntity.ok().body(tokens);
}
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Authentication failed");
}