diff --git a/auth-view/src/pages/LoginPage.tsx b/auth-view/src/pages/LoginPage.tsx index dfd9ee6..d1c77ea 100644 --- a/auth-view/src/pages/LoginPage.tsx +++ b/auth-view/src/pages/LoginPage.tsx @@ -33,7 +33,7 @@ export default function LoginPage() { const res = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ email, password }), + body: JSON.stringify({ email: email.toLowerCase(), password }), }); const data = await res.json(); if (data.success && data.payload?.token) { diff --git a/auth-view/src/pages/RegisterPage.tsx b/auth-view/src/pages/RegisterPage.tsx index d9c752c..00e4657 100644 --- a/auth-view/src/pages/RegisterPage.tsx +++ b/auth-view/src/pages/RegisterPage.tsx @@ -32,7 +32,7 @@ export default function RegisterPage() { const res = await fetch("/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ username, email, password, confirmPassword }), + body: JSON.stringify({ username, email: email.toLowerCase(), password, confirmPassword }), }); const data = await res.json(); if (data.success && data.payload?.token) { diff --git a/gateway-service/src/main/java/com/posthub/gateway/service/AuthService.java b/gateway-service/src/main/java/com/posthub/gateway/service/AuthService.java index f8fa9c2..091ef8e 100644 --- a/gateway-service/src/main/java/com/posthub/gateway/service/AuthService.java +++ b/gateway-service/src/main/java/com/posthub/gateway/service/AuthService.java @@ -35,7 +35,7 @@ public class AuthService { private final PasswordEncoder passwordEncoder; public Mono> login(LoginRequest request) { - return userRepository.findByEmail(request.getEmail()) + return userRepository.findByEmail(request.getEmail().toLowerCase()) .switchIfEmpty(Mono.error(new ResponseStatusException( HttpStatus.UNAUTHORIZED, ApiErrorMessage.INVALID_USER_OR_PASSWORD.getMessage()))) .flatMap(user -> { @@ -67,7 +67,7 @@ public class AuthService { return userRepository.findByUsername(request.getUsername()) .flatMap(existing -> Mono.error(new ResponseStatusException( HttpStatus.CONFLICT, ApiErrorMessage.USERNAME_ALREADY_EXISTS.getMessage(request.getUsername())))) - .switchIfEmpty(userRepository.existsByEmail(request.getEmail()) + .switchIfEmpty(userRepository.existsByEmail(request.getEmail().toLowerCase()) .flatMap(exists -> { if (exists) { return Mono.error(new ResponseStatusException( @@ -75,7 +75,7 @@ public class AuthService { } User user = new User(); user.setUsername(request.getUsername()); - user.setEmail(request.getEmail()); + user.setEmail(request.getEmail().toLowerCase()); user.setPassword(passwordEncoder.encode(request.getPassword())); user.setRegistrationStatus(RegistrationStatus.ACTIVE); user.setRole(UserRole.USER);