You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
1.0 KiB
22 lines
1.0 KiB
4 years ago
|
from flask_wtf import FlaskForm
|
||
|
from wtforms import StringField, PasswordField, BooleanField, SubmitField, TextAreaField
|
||
|
from wtforms.validators import DataRequired, EqualTo, ValidationError, Length
|
||
|
from app.models import Player
|
||
|
|
||
|
class LoginForm(FlaskForm):
|
||
|
username = StringField('Username', validators=[DataRequired()])
|
||
|
password = PasswordField('Password', validators=[DataRequired()])
|
||
|
remember_me = BooleanField('Remember Me', default=True)
|
||
|
submit = SubmitField('Sign In')
|
||
|
|
||
|
class RegistrationForm(FlaskForm):
|
||
|
username = StringField('Username', validators=[DataRequired(), Length(min=0, max=64)])
|
||
|
password = PasswordField('Password', validators=[DataRequired(), Length(min=0, max=128)])
|
||
|
password2 = PasswordField(
|
||
|
'Repeat Password', validators=[DataRequired(), EqualTo('password')])
|
||
|
submit = SubmitField('Register')
|
||
|
|
||
|
def validate_username(self, username):
|
||
|
player = Player.query.filter_by(name=username.data).first()
|
||
|
if player is not None:
|
||
|
raise ValidationError('Please use a different username.')
|