diff --git a/endpoints/signup.post.py b/endpoints/signup.post.py index 05da3da..2a692ce 100644 --- a/endpoints/signup.post.py +++ b/endpoints/signup.post.py @@ -3,7 +3,7 @@ from sqlalchemy.orm import Session from core.database import get_db from models.user import User from schemas.user import UserCreate, UserResponse -from helpers.user_helpers import create_user +from helpers.user_helpers import create_user, get_user_by_email router = APIRouter() @@ -12,5 +12,12 @@ async def signup( user_data: UserCreate, db: Session = Depends(get_db) ): + existing_user = get_user_by_email(db, user_data.email) + if existing_user: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="Email already registered" + ) + new_user = create_user(db, user_data) return new_user \ No newline at end of file