Skip to content

Commit

Permalink
fix(utils): generate unique username vs cyrillic
Browse files Browse the repository at this point in the history
For cyrillic names on social accounts - the encode and decode operations result in replacing all chars with empty string. And later in try-except block clean_username does not raise a ValidationError, so empty string username is considered valid. As a result, "user" is returned at first iteration and other txts are not even being processed
  • Loading branch information
Nazarinh0 authored Feb 28, 2024
1 parent 6f0ced9 commit 8afc3a6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions allauth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def _generate_unique_username_base(txts, regex=None):
continue
username = unicodedata.normalize("NFKD", force_str(txt))
username = username.encode("ascii", "ignore").decode("ascii")
if len(username) == 0:
continue
username = force_str(re.sub(regex, "", username).lower())
# Django allows for '@' in usernames in order to accommodate for
# project wanting to use email for username. In allauth we don't
Expand Down

0 comments on commit 8afc3a6

Please sign in to comment.