Skip to content

Differentiate manual login failures for unknown account vs invalid password#48

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-login-error-messages
Draft

Differentiate manual login failures for unknown account vs invalid password#48
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-login-error-messages

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown

Manual login currently returns the same error for both nonexistent email/username and incorrect password, which makes recovery flow ambiguous for real users. This change updates the JWT login path to return distinct failure messages for those two cases while preserving existing token/lockout behavior.

  • Auth error mapping in token serializer

    • Updated MyTokenObtainPairSerializer.validate() in backend/wordgen/auth_views.py.
    • Kept super().validate(...) as the primary auth path, then mapped failed auth outcomes into:
      • No account found for this email/username.
      • Incorrect password.
    • Applied lookup for both username and email login inputs.
  • Focused auth tests

    • Extended AuthTokenTest in backend/wordgen/tests.py to assert message-level behavior for:
      • wrong password on existing user
      • nonexistent username
      • nonexistent email
  • Behavioral example

    # POST /api/user/token/
    {"username": "missing-user", "password": "StrongPass1!"}
    # -> 401 {"detail": "No account found for this email/username."}
    
    {"username": "authuser", "password": "wrong"}
    # -> 401 {"detail": "Incorrect password."}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.pwnedpasswords.com
    • Triggering command: /usr/bin/python python manage.py test --verbosity=1 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested review from Copilot and removed request for Copilot May 12, 2026 20:23
@vercel

vercel Bot commented May 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pii-casso Ready Ready Preview, Comment May 12, 2026 8:34pm

Copilot AI requested review from Copilot and removed request for Copilot May 12, 2026 20:30
Agent-Logs-Url: https://github.com/yokesh-kumar-M/Piicasso/sessions/dda898e3-74e0-43a7-ba65-b718c073ad02

Co-authored-by: yokesh-kumar-M <119868649+yokesh-kumar-M@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 12, 2026 20:32
Copilot AI changed the title [WIP] Fix login error messages for non-existent email or wrong password Differentiate manual login failures for unknown account vs invalid password May 12, 2026
Copilot AI requested a review from yokesh-kumar-M May 12, 2026 20:34
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.

Login shows the same error for non-existent email/username and wrong password

2 participants