pparth602

Auth Controller

Nov 1st, 2022
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | Software | 0 0
  1. @CrossOrigin(origins = "*", maxAge = 3600)
  2. @RestController
  3. @RequestMapping("/api/auth")
  4. @RequiredArgsConstructor
  5. public class AuthController {
  6.  
  7.   private final AuthenticationManager authenticationManager;
  8.   private final AuthService authService;
  9.  
  10.   @PostMapping("/signin")
  11.   public ResponseEntity<?> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) {
  12.     return authService.authenticateUser(loginRequest);
  13.   }
  14.  
  15.   @PostMapping("/signup")
  16.   public ResponseEntity<?> registerUser(@Valid @RequestBody SignupRequest signUpRequest) {
  17.     return authService.registerUser(signUpRequest);
  18.   }
  19.  
  20.   @GetMapping("/verify/{verificationCode}")
  21.   public String verifyUser(@PathVariable("verificationCode") String verificationCode) {
  22.     if (authService.verify(verificationCode)) {
  23.       return "verify_success";
  24.     } else {
  25.       return "verify_fail";
  26.     }
  27.   }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment