views: accept only user credentials without whitespace

Check the presence of whitespace for new usernames or passwords.

Usernames with whitespace can't be deleted because whitespace
is the separator of each element selected in the form.
master
Alejandro Sirgo Rica 2025-02-12 14:17:49 +01:00
parent 4c21e370a3
commit b3b47ac0cb
1 changed files with 8 additions and 0 deletions

View File

@ -3485,6 +3485,14 @@ def user_add_post():
flash(form.errors, category='error')
return redirect(url_for('users'))
if re.search(r'\s', form.username.data):
flash(_('The username cannot contain spaces'), category='error')
return redirect(url_for('users'))
if re.search(r'\s', form.pwd.data):
flash(_('The password cannot contain spaces'), category='error')
return redirect(url_for('users'))
if get_user(form.username.data):
flash(_('This username already exists'), category='error')
return redirect(url_for('users'))