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 an issue with empty username when user creation disrupted #29

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

Anexen
Copy link
Contributor

@Anexen Anexen commented Mar 10, 2024

Description

If for some reason the user creation is interrupted in the middle, the user with an empty username remains in the database. This makes the account unusable and prevents the creation of new users with the following error:

UniqueViolation: duplicate key value violates unique constraint "auth_user_username_key"
DETAIL:  Key (username)=() already exists.

This PR resolves this issue and also decreases the number of database queries when a user logs in.

Contains

  • Breaking Changes
  • New/Update documentation
  • CI/CD modifications

Changes

  • Fix an issue with empty username when user creation disrupted
  • Reduce the number of database queries when user logs in.

@chrismaille
Copy link
Collaborator

chrismaille commented Mar 12, 2024

Hi @Anexen, thank you for the contribution.

Can you give, in more details, the user creation interruption you got? Did you change anything on standard user model behavior in your project?

@chrismaille chrismaille changed the base branch from main to develop March 12, 2024 14:02
@chrismaille chrismaille merged commit 2830f8c into megalus:develop Mar 12, 2024
1 of 28 checks passed
@chrismaille chrismaille mentioned this pull request Mar 12, 2024
3 tasks
@Anexen
Copy link
Contributor Author

Anexen commented Mar 12, 2024

@chrismaille, I didn't change the standard user model. I think there was a network issue somewhere between user_model.objects.get_or_create and subsequent user.save(). For instance, if the check_first_super_user function failed due to a timeout, it could leave the user with an empty username in the database, thereby preventing the creation of new users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants