Remove any non alphanum character present in email for username

This commit is contained in:
PCoder 2020-03-06 12:25:42 +05:30
parent ea79fafb08
commit a995f418b2

View file

@ -105,6 +105,9 @@ def assign_username(user):
logger.debug("Inferred username from name is empty. So, "
"inferring from email now.")
user.username = user.email[0:user.email.index("@")]
user.username = "".join(
[char for char in user.username if char.isalnum()]
).lower()
except Exception as ex:
logger.debug("Exception %s" % str(ex))
user.username = get_random_string(