From 3351499e736a22772af5a83e37c09f95af2c68b8 Mon Sep 17 00:00:00 2001 From: Peter Vacho Date: Fri, 3 Jan 2025 17:12:10 +0100 Subject: [PATCH] Handle email taken during registration --- src/api/users.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/users.py b/src/api/users.py index 93a5fe9..92dc6d0 100644 --- a/src/api/users.py +++ b/src/api/users.py @@ -99,6 +99,10 @@ async def register(reg_data: Annotated[RegisterData, Body()]) -> UserData: if user is not None: raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="Username already taken") + user = await User.find_one(User.email == reg_data.email) + if user is not None: + raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="Email already taken") + user = await reg_data.create_user() return UserData.from_user(user)