Skip to content

fix: signup existing user check#41

Merged
A-lexisL merged 1 commit intodevfrom
fix/signup-check-user-exist
Jan 11, 2026
Merged

fix: signup existing user check#41
A-lexisL merged 1 commit intodevfrom
fix/signup-check-user-exist

Conversation

@A-lexisL
Copy link
Contributor

Note: current method use user_model.Object.get_or_create() to create a user, which will not call set_unusable_password, so has_usable_password will return true, leading to 409 in normal setup workflow.

@A-lexisL A-lexisL self-assigned this Jan 11, 2026
Copilot AI review requested due to automatic review settings January 11, 2026 14:19
@A-lexisL A-lexisL added the bug Something isn't working label Jan 11, 2026
@A-lexisL A-lexisL merged commit cc56d84 into dev Jan 11, 2026
10 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request attempts to fix an issue with the existing user check during signup. The problem stems from using get_or_create() to create users, which doesn't call set_unusable_password(), causing has_usable_password() to incorrectly return True for newly created users and triggering a false 409 error.

Changes:

  • Replaces user.has_usable_password() check with user.password check in the signup endpoint

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{"error": "Failed to create user session"}, status=500
)
if user.has_usable_password():
if user.password:
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The check if user.password: is insufficient and potentially incorrect. This will treat users with unusable passwords (marked with special prefixes like "!") as if they have valid passwords, which could prevent legitimate signups.

The underlying issue is that user_model.objects.get_or_create() in create_user_session() doesn't call set_unusable_password(), leaving the password field as an empty string. A more robust solution would be to:

  1. Modify create_user_session() to explicitly set an unusable password when creating new users, OR
  2. Check both if the password exists AND if it's usable with a condition like: if user.password and user.has_usable_password():

The current change could block users who have unusable password markers from completing signup.

Suggested change
if user.password:
if user.password and user.has_usable_password():

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant