diff options
author | Donald Stufft <donald@stufft.io> | 2013-07-25 22:26:07 -0400 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-07-25 22:26:07 -0400 |
commit | f178bf35a7a0e55b4e7720ccff41e2fb5e5b7d30 (patch) | |
tree | 7f8775cff323dfe5d837ec3c8140c45d9e35c298 | |
parent | 0e4ea1b3e8c2dbdb15f617260aaae401c1cbac59 (diff) | |
download | decorator-f178bf35a7a0e55b4e7720ccff41e2fb5e5b7d30.tar.gz |
Suggest better usernames for openid
-rw-r--r-- | webui.py | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -3307,9 +3307,22 @@ class WebUI: username = username.rsplit('@', 1)[0] if not username: username = "nonamegiven" - username = username.replace(' ','.') - username = re.sub('[^a-zA-Z0-9._]','',username) + + username = username.strip() + username = username.replace(' ', '.') + username = re.sub('[^a-zA-Z0-9._]', '', username) error = 'Please choose a username to complete registration' + + if not username: + username = "nonamegiven" + + alphanums = set(string.ascii_letters + string.digits) + if not safe_username.match(username): + if username[0] not in alphanums: + username = "openid_" + username + if username[-1] not in alphanums: + username = username + "_user" + if self.store.has_user(username, case_sensitive=False): suffix = 2 while self.store.has_user("%s_%d" % (username, suffix)): |