bots: Add validation to add_bot_backend to prevent empty short names

Fixes #5487
This commit is contained in:
Sampriti Panda
2017-06-21 17:16:58 +05:30
committed by showell
parent e49afe3ebc
commit 5dc053d6fb
3 changed files with 22 additions and 2 deletions

View File

@@ -18,6 +18,13 @@ def check_full_name(full_name_raw):
raise JsonableError(_("Invalid characters in name!"))
return full_name
def check_short_name(short_name_raw):
# type: (Text) -> Text
short_name = short_name_raw.strip()
if len(short_name) == 0:
raise JsonableError(_("Bad name or username"))
return short_name
def check_change_full_name(user_profile, full_name_raw, acting_user):
# type: (UserProfile, Text, UserProfile) -> Text
"""Verifies that the user's proposed full name is valid. The caller