diff --git a/src/main/java/com/safetypin/authentication/controller/AuthenticationController.java b/src/main/java/com/safetypin/authentication/controller/AuthenticationController.java index d7e04c022585ab7af770391f858c6b1cf6d11a97..ee3bcfc0e1aabb7a1fd410f60bebb12c5569ab3f 100644 --- a/src/main/java/com/safetypin/authentication/controller/AuthenticationController.java +++ b/src/main/java/com/safetypin/authentication/controller/AuthenticationController.java @@ -65,16 +65,22 @@ public class AuthenticationController { try { return ResponseEntity.ok(authenticationService.loginUser(email, password)); } catch (InvalidCredentialsException e){ - return ResponseEntity.status(HttpStatus.UNAUTHORIZED) - .body(e.getMessage()); + AuthResponse response = new AuthResponse(false, e.getMessage(), null); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } } // Endpoint for social login @PostMapping("/login-social") - public User loginSocial(@RequestParam String email) { - return authenticationService.loginSocial(email); + public ResponseEntity<Object> loginSocial(@RequestParam String email) { + try { + return ResponseEntity.ok(authenticationService.loginSocial(email)); + } catch (InvalidCredentialsException e){ + AuthResponse response = new AuthResponse(false, e.getMessage(), null); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); + } + }