mail lowcase
This commit is contained in:
@@ -33,7 +33,7 @@ export default function LoginPage() {
|
|||||||
const res = await fetch("/api/auth/login", {
|
const res = await fetch("/api/auth/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ email, password }),
|
body: JSON.stringify({ email: email.toLowerCase(), password }),
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (data.success && data.payload?.token) {
|
if (data.success && data.payload?.token) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default function RegisterPage() {
|
|||||||
const res = await fetch("/api/auth/register", {
|
const res = await fetch("/api/auth/register", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
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();
|
const data = await res.json();
|
||||||
if (data.success && data.payload?.token) {
|
if (data.success && data.payload?.token) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class AuthService {
|
|||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
public Mono<RagResponse<UserProfileDTO>> login(LoginRequest request) {
|
public Mono<RagResponse<UserProfileDTO>> login(LoginRequest request) {
|
||||||
return userRepository.findByEmail(request.getEmail())
|
return userRepository.findByEmail(request.getEmail().toLowerCase())
|
||||||
.switchIfEmpty(Mono.error(new ResponseStatusException(
|
.switchIfEmpty(Mono.error(new ResponseStatusException(
|
||||||
HttpStatus.UNAUTHORIZED, ApiErrorMessage.INVALID_USER_OR_PASSWORD.getMessage())))
|
HttpStatus.UNAUTHORIZED, ApiErrorMessage.INVALID_USER_OR_PASSWORD.getMessage())))
|
||||||
.flatMap(user -> {
|
.flatMap(user -> {
|
||||||
@@ -67,7 +67,7 @@ public class AuthService {
|
|||||||
return userRepository.findByUsername(request.getUsername())
|
return userRepository.findByUsername(request.getUsername())
|
||||||
.flatMap(existing -> Mono.<User>error(new ResponseStatusException(
|
.flatMap(existing -> Mono.<User>error(new ResponseStatusException(
|
||||||
HttpStatus.CONFLICT, ApiErrorMessage.USERNAME_ALREADY_EXISTS.getMessage(request.getUsername()))))
|
HttpStatus.CONFLICT, ApiErrorMessage.USERNAME_ALREADY_EXISTS.getMessage(request.getUsername()))))
|
||||||
.switchIfEmpty(userRepository.existsByEmail(request.getEmail())
|
.switchIfEmpty(userRepository.existsByEmail(request.getEmail().toLowerCase())
|
||||||
.flatMap(exists -> {
|
.flatMap(exists -> {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
return Mono.<User>error(new ResponseStatusException(
|
return Mono.<User>error(new ResponseStatusException(
|
||||||
@@ -75,7 +75,7 @@ public class AuthService {
|
|||||||
}
|
}
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUsername(request.getUsername());
|
user.setUsername(request.getUsername());
|
||||||
user.setEmail(request.getEmail());
|
user.setEmail(request.getEmail().toLowerCase());
|
||||||
user.setPassword(passwordEncoder.encode(request.getPassword()));
|
user.setPassword(passwordEncoder.encode(request.getPassword()));
|
||||||
user.setRegistrationStatus(RegistrationStatus.ACTIVE);
|
user.setRegistrationStatus(RegistrationStatus.ACTIVE);
|
||||||
user.setRole(UserRole.USER);
|
user.setRole(UserRole.USER);
|
||||||
|
|||||||
Reference in New Issue
Block a user