Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix login when email domain contains capital symbols and user was created after invitation to some org #7906

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Login when the domain of a user email contains capital symbols and a user was created after being invited to an org
(<https://github.com/cvat-ai/cvat/pull/7906>)
3 changes: 2 additions & 1 deletion cvat/apps/organizations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def create(self, validated_data):
user_email = membership_data['user']['email']
user = User.objects.create_user(username=user_email, email=user_email)
user.set_unusable_password()
email = EmailAddress.objects.create(user=user, email=user_email, primary=True, verified=False)
# User.objects.create_user(...) normalizes passed email and user.email can be different from original user_email
email = EmailAddress.objects.create(user=user, email=user.email, primary=True, verified=False)
Comment on lines +106 to +107
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use normalized email to ensure case-insensitive handling.

Consider adding a comment explaining why normalization is necessary, for future maintainability.

+ # Normalize email to handle case-insensitivity
  email = EmailAddress.objects.create(user=user, email=user.email, primary=True, verified=False)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# User.objects.create_user(...) normalizes passed email and user.email can be different from original user_email
email = EmailAddress.objects.create(user=user, email=user.email, primary=True, verified=False)
# User.objects.create_user(...) normalizes passed email and user.email can be different from original user_email
# Normalize email to handle case-insensitivity
email = EmailAddress.objects.create(user=user, email=user.email, primary=True, verified=False)

user.save()
email.save()
del membership_data['user']
Expand Down
Loading