This commit is contained in:
vladp
2025-11-28 14:30:25 +07:00
parent e6d7fa7aae
commit 3a9980fd86
3 changed files with 3 additions and 3 deletions
@@ -5,9 +5,11 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
public class LoginRequest { public class LoginRequest {
@NotBlank(message = "error.not.blank") @Email(message = "error.not.email") @Size(max = 128) @NotBlank(message = "error.not.blank") @Email(message = "error.not.email") @Size(max = 128)
@@ -13,7 +13,6 @@ import java.time.LocalDate;
public record RegisterRequest( public record RegisterRequest(
@NotBlank(message = "error.name.length") @NotBlank(message = "error.name.length")
@Size(min = 2)
String fullName, String fullName,
String companyName, String companyName,
@@ -38,8 +38,7 @@ public class AuthService {
@Transactional @Transactional
public AuthToken register(RegisterRequest registerRequest) { public AuthToken register(RegisterRequest registerRequest) {
if (userRepository.existsByEmail(registerRequest.email())) { if (userRepository.existsByEmail(registerRequest.email())) {
throw new UserAlreadyExistsException(messageSource.getMessage("error.user.exists", null, throw new UserAlreadyExistsException("User already exists with email: " + registerRequest.email());
Locale.getDefault()));
} }
User user = new User(); User user = new User();