Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions etebase_server/fastapi/routers/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def signup_save(data: SignupIn, request: Request) -> UserType:
with transaction.atomic():
try:
user_queryset = get_user_queryset(User.objects.all(), CallbackContext(request.path_params))
instance = user_queryset.get(**{User.USERNAME_FIELD: user_data.username.lower()})
user_queryset.get(**{User.USERNAME_FIELD: user_data.username.lower()})
raise HttpError("user_exists", "User already exists", status_code=status.HTTP_409_CONFLICT)
except User.DoesNotExist:
# Create the user and save the casing the user chose as the first name
try:
Expand All @@ -249,9 +250,6 @@ def signup_save(data: SignupIn, request: Request) -> UserType:
except Exception as e:
raise HttpError("generic", str(e))

if hasattr(instance, "userinfo"):
raise HttpError("user_exists", "User already exists", status_code=status.HTTP_409_CONFLICT)

models.UserInfo.objects.create(**data.dict(exclude={"user"}), owner=instance)
return instance

Expand Down