Don't let users change their fullname to be whitespace.

(imported from commit 015fc7cbc06acd5057952a3f09a9b6d3fe68d9fd)
This commit is contained in:
Tim Abbott
2012-12-05 14:56:31 -05:00
parent a8cd5539ff
commit 41ec4d44a0
2 changed files with 7 additions and 4 deletions

View File

@@ -212,7 +212,10 @@ def compute_mit_user_fullname(email):
if proc.returncode == 0:
# Parse e.g. 'starnine:*:84233:101:Athena Consulting Exchange User,,,:/mit/starnine:/bin/bash'
# for the 4th passwd entry field, aka the person's name.
return out.split(':')[4].split(',')[0]
hesiod_name = out.split(':')[4].split(',')[0].strip()
if hesiod_name == "":
return email
return hesiod_name
elif match_user:
return match_user.group(1).lower() + "@" + match_user.group(2).upper()[1:]
except:

View File

@@ -85,13 +85,13 @@ def accounts_register(request):
domain = email.split('@')[-1]
(realm, _) = Realm.objects.get_or_create(domain=domain)
# FIXME: sanitize email addresses and fullname
if mit_beta_user:
user = User.objects.get(email=email)
do_activate_user(user)
do_change_password(user, password)
do_change_full_name(user.userprofile, full_name)
else:
# FIXME: sanitize email addresses
user = do_create_user(email, password, realm, full_name, short_name)
add_default_subs(user)
@@ -855,8 +855,8 @@ def json_change_settings(request, user_profile, full_name=POST,
do_change_password(user_profile.user, new_password)
result = {}
if user_profile.full_name != full_name:
do_change_full_name(user_profile, full_name)
if user_profile.full_name != full_name and full_name.strip() != "":
do_change_full_name(user_profile, full_name.strip())
result['full_name'] = full_name
if user_profile.enable_desktop_notifications != enable_desktop_notifications: