Remove current_app and current_user usage in forms.

This commit is contained in:
Patrick Jentsch
2021-09-13 16:36:48 +02:00
parent 10483c1e45
commit 81ed16603d
8 changed files with 34 additions and 29 deletions

View File

@ -1,5 +1,8 @@
from flask import Blueprint
USERNAME_REGEX = '^[A-Za-zÄÖÜäöüß0-9_.]*$'
bp = Blueprint('auth', __name__)
from . import routes

View File

@ -1,4 +1,4 @@
from flask import current_app
from . import USERNAME_REGEX
from ..models import User
from flask_wtf import FlaskForm
from wtforms import (BooleanField, PasswordField, StringField, SubmitField,
@ -18,7 +18,7 @@ class RegistrationForm(FlaskForm):
username = StringField(
'Username',
validators=[DataRequired(), Length(1, 64),
Regexp(current_app.config['NOPAQUE_USERNAME_REGEX'],
Regexp(USERNAME_REGEX,
message='Usernames must have only letters, numbers,'
' dots or underscores')]
)