Complete JWT token support.

This commit is contained in:
Paulo Gustavo Veiga
2024-02-04 20:53:24 -08:00
parent 082f2614e3
commit 34a5328a2c
5 changed files with 64 additions and 43 deletions

View File

@@ -55,11 +55,11 @@ public class JwtAuthController {
public ResponseEntity<?> createAuthenticationToken(@RequestBody RestJwtUser user, @NotNull HttpServletResponse response) throws Exception {
// Is a valid user ?
authenticate(user.getUsername(), user.getPassword());
authenticate(user.getEmail(), user.getPassword());
// Create token ...
final UserDetails userDetails = userDetailsService
.loadUserByUsername(user.getUsername());
.loadUserByUsername(user.getEmail());
final String token = jwtTokenUtil.generateJwtToken(userDetails);

View File

@@ -33,21 +33,20 @@ import org.jetbrains.annotations.NotNull;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RestJwtUser {
private String username;
private String email;
private String password;
public RestJwtUser(@NotNull String username, @NotNull String password) {
this.setUsername(username);
public RestJwtUser(@NotNull String email, @NotNull String password) {
this.setEmail(email);
this.setPassword(password);
}
public String getUsername() {
return this.username;
public String getEmail() {
return this.email;
}
public void setUsername(String username) {
this.username = username;
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {