Handle email taken during registration
This commit is contained in:
parent
d36db8c04f
commit
3351499e73
|
@ -99,6 +99,10 @@ async def register(reg_data: Annotated[RegisterData, Body()]) -> UserData:
|
||||||
if user is not None:
|
if user is not None:
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="Username already taken")
|
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()
|
user = await reg_data.create_user()
|
||||||
return UserData.from_user(user)
|
return UserData.from_user(user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue