From 5cb0644b462d530afebce72bfdcf0119a38c8b89 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:48:09 +1200 Subject: [PATCH] disallow spaces in user names #320 --- app/auth/forms.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/auth/forms.py b/app/auth/forms.py index b7f02939..66692460 100644 --- a/app/auth/forms.py +++ b/app/auth/forms.py @@ -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()