@PostMapping
public ResponseEntity iniciarSesion(@Valid @RequestBody DatosAutenticacion datos) {
var authenticationToken =
new UsernamePasswordAuthenticationToken(datos.login(), datos.contrasena());
var autenticacion = manager.authenticate(authenticationToken);
var tokenJWT =
tokenService.generarToken((Usuario) autenticacion.getPrincipal());
return ResponseEntity.ok(new DatosTokenJWT(tokenJWT));
}
public record DatosTokenJWT(String token) {
}