2017-05-17 20:16:30 +02:00
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
from wtforms import StringField, PasswordField, BooleanField
|
|
|
|
from wtforms.validators import DataRequired, Email, Length, EqualTo
|
|
|
|
|
2017-05-18 18:25:54 +02:00
|
|
|
|
2017-05-17 20:16:30 +02:00
|
|
|
class LoginForm(FlaskForm):
|
2017-05-18 18:25:54 +02:00
|
|
|
'''
|
|
|
|
Form Login
|
|
|
|
'''
|
|
|
|
email = StringField(
|
|
|
|
'Email',
|
|
|
|
validators=[
|
|
|
|
DataRequired(),
|
|
|
|
Email()
|
|
|
|
]
|
|
|
|
)
|
|
|
|
password = PasswordField(
|
|
|
|
'Password',
|
|
|
|
validators=[
|
|
|
|
DataRequired()
|
|
|
|
]
|
|
|
|
)
|
2017-05-17 20:16:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SignupForm(FlaskForm):
|
2017-05-18 18:25:54 +02:00
|
|
|
'''
|
|
|
|
Form signup
|
|
|
|
'''
|
|
|
|
username = StringField(
|
|
|
|
'Username',
|
|
|
|
validators=[
|
|
|
|
DataRequired(),
|
|
|
|
Length(5, 30, '''
|
|
|
|
You can not have less than 5 characters or more 30.
|
|
|
|
''')
|
|
|
|
]
|
|
|
|
)
|
|
|
|
email = StringField(
|
|
|
|
'Email',
|
|
|
|
validators=[
|
|
|
|
DataRequired(),
|
|
|
|
Email(),
|
|
|
|
Length(1, 254, 'Too long.')
|
|
|
|
]
|
|
|
|
)
|
|
|
|
password = PasswordField(
|
|
|
|
'Password',
|
|
|
|
validators=[
|
|
|
|
DataRequired(),
|
|
|
|
EqualTo(
|
|
|
|
'password_confirm',
|
|
|
|
'Passwords are not the same.'
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
password_confirm = PasswordField('Repeat password')
|
|
|
|
accept_tos = BooleanField(
|
|
|
|
'I accept the terms and conditions.',
|
|
|
|
validators=[
|
|
|
|
DataRequired('Please accept the terms and conditions.')
|
|
|
|
]
|
|
|
|
)
|
2017-05-17 20:16:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
class EmailResetPasswordForm(FlaskForm):
|
2017-05-18 18:25:54 +02:00
|
|
|
'''
|
|
|
|
Form send email reset password
|
|
|
|
'''
|
|
|
|
email = StringField(
|
|
|
|
'Email',
|
|
|
|
validators=[
|
|
|
|
DataRequired(),
|
|
|
|
Email()
|
|
|
|
]
|
|
|
|
)
|
2017-05-17 20:16:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ResetPasswordForm(FlaskForm):
|
2017-05-18 18:25:54 +02:00
|
|
|
'''
|
|
|
|
Form update password
|
|
|
|
'''
|
|
|
|
password = PasswordField(
|
|
|
|
'Password',
|
|
|
|
validators=[
|
|
|
|
DataRequired(),
|
|
|
|
EqualTo(
|
|
|
|
'password_confirm',
|
|
|
|
'Passwords are not the same.'
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
password_confirm = PasswordField('Repeat password')
|