Conversation
Co-authored-by: iragm <71519690+iragm@users.noreply.github.com>
|
@copilot is there a built in way that django-allauth handles this and would that be cleaner? We have many users with @ in their ueranmes already |
…rnames Co-authored-by: iragm <71519690+iragm@users.noreply.github.com>
Yes — allauth provides The change creates Existing users with |
There was a problem hiding this comment.
Pull request overview
Adds a consistent username validation rule across django-allauth signup and the site’s username change form by disallowing @ in usernames, avoiding confusion with email-based login.
Changes:
- Configure django-allauth to use a shared username validator list via
ACCOUNT_USERNAME_VALIDATORS. - Introduce a reusable
validate_username_no_at_symbolvalidator (and aUSERNAME_VALIDATORSbundle). - Add form-level validation + tests covering both the change-username flow and allauth adapter behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
fishauctions/settings.py |
Wires allauth username validation to the project’s validator list. |
auctions/validators.py |
Adds the @-blocking username validator and exported USERNAME_VALIDATORS. |
auctions/forms.py |
Enforces the same rule in ChangeUsernameForm.clean_username(). |
auctions/tests.py |
Adds regression tests for both form validation and allauth adapter validation. |
Usernames containing
@could be confused with email addresses or @-mentions. This adds validation to reject them at both registration and username-change. Existing users with@in their usernames are unaffected.Changes
auctions/validators.py(new) —validate_username_no_at_symbolvalidator and aUSERNAME_VALIDATORSlist combining Django's default username validators with the new onesettings.py—ACCOUNT_USERNAME_VALIDATORSset to"auctions.validators.USERNAME_VALIDATORS", so allauth's adapter enforces the restriction across all signup flows nativelyChangeUsernameForm.clean_username— delegates to the sharedvalidate_username_no_at_symbolvalidator (this form is a plain Django ModelForm, not part of allauth)ChangeUsernameFormTest(form-level) andCustomSignupFormTest(verifies allauth adapter rejects@usernames via the configured validators)Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.