1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-12 21:40:41 +00:00
AdvLabDB/advlabdb/forms.py
2021-04-02 00:33:50 +02:00

23 lines
871 B
Python

from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError
from advlabdb.models import User
class RegistrationForm(FlaskForm):
email = StringField("Email",
validators=[DataRequired(), Email()])
admin = BooleanField("Admin")
submit = SubmitField("Sign Up")
def validate_email(self, email):
user = User.query.filter_by(email=email.data.lower()).first()
if user:
raise ValidationError("A user with this email address is already registered!")
class LoginForm(FlaskForm):
email = StringField("Email",
validators=[DataRequired(), Email()])
password = PasswordField("Password", validators=[DataRequired()])
submit = SubmitField("Login")