disallow spaces in user names #320

This commit is contained in:
rimu 2024-09-09 16:48:09 +12:00
parent 34203bd92a
commit 5cb0644b46

View file

@ -32,6 +32,9 @@ class RegistrationForm(FlaskForm):
raise ValidationError(_l('An account with this email address already exists.'))
def validate_user_name(self, user_name):
user_name.data = user_name.data.strip()
if ' ' in user_name.data:
raise ValidationError(_l('User names cannot contain spaces.'))
if '@' in user_name.data:
raise ValidationError(_l('User names cannot contain @.'))
user = User.query.filter(func.lower(User.user_name) == func.lower(user_name.data.strip())).filter_by(ap_id=None).first()