Skip to content

Commit

Permalink
Add tests for default name filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Jan 6, 2023
1 parent 97bea2f commit 221844a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions misago/oauth2/validation.py
Expand Up @@ -32,16 +32,19 @@ def filter_user_data_with_filters(request, user, user_data, filters):


def filter_name(user, name):
if user and user.username == name:
return name

clean_name = "".join(
[c for c in unidecode(name.replace(" ", "_")) if c.isalnum() or c == "_"]
)

if not clean_name:
clean_name = "User_%s" % get_random_string(4)

if user and user.username == clean_name:
return clean_name # No change in name

if not clean_name.replace("_", ""):
clean_name = "User_%s" % get_random_string(4)

clean_name_root = clean_name
while True:
try:
Expand Down

0 comments on commit 221844a

Please sign in to comment.