From 221844a66dbe3e10915311a29a7be2f91be6831d Mon Sep 17 00:00:00 2001 From: rafalp Date: Fri, 6 Jan 2023 20:53:54 +0100 Subject: [PATCH] Add tests for default name filter --- misago/oauth2/validation.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misago/oauth2/validation.py b/misago/oauth2/validation.py index 0c86d7aa0..b32c4dded 100644 --- a/misago/oauth2/validation.py +++ b/misago/oauth2/validation.py @@ -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: