INC-1 add login function

This commit is contained in:
vladp
2025-11-25 11:59:37 +07:00
parent 3626a51b57
commit 74ae769de0
9 changed files with 139 additions and 41 deletions
@@ -8,7 +8,9 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import ru.soune.no_copy.exception.NotValidationPasswordException;
import ru.soune.no_copy.exception.UserAlreadyExistsException;
import ru.soune.no_copy.exception.UserNotFoundException;
import java.util.Map;
@@ -39,4 +41,26 @@ public class GlobalExceptionHandler {
"message" ,ex.getMessage()
));
}
@ExceptionHandler(UserNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ResponseEntity<?> handleUserNotFoundException(UserNotFoundException ex) {
return ResponseEntity.
badRequest()
.body(Map.of(
"success", false,
"message" ,ex.getMessage()
));
}
@ExceptionHandler(NotValidationPasswordException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
public ResponseEntity<?> handleNotValidationPasswordException(NotValidationPasswordException ex) {
return ResponseEntity.
badRequest()
.body(Map.of(
"success", false,
"message" ,ex.getMessage()
));
}
}