Skip to content

Commit

Permalink
update class AuthenAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhthien2000 committed Jan 11, 2024
1 parent 9775e4a commit 0343ac6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/ndt/java/spring/controller/AuthenAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,16 @@ public ResponseEntity<?> signUp(String username, String password) {

return ResponseEntity.ok(newUser);
}

@PostMapping("/auth/signup")
public ResponseEntity<?> signUp(@RequestBody @Valid User user) {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
// String password = encoder.encode("Abc@1234");

// User user = new User(username,encoder.encode(password));
user.setPassword(encoder.encode(user.getPassword()));
User newUser = repository.save(user);
AuthenResponse response = new AuthenResponse(newUser.getEmail(), "Singup success !!");
return ResponseEntity.ok(response);
}
}

0 comments on commit 0343ac6

Please sign in to comment.