Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

forms.py 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  1. from flask_wtf import FlaskForm
  2. from wtforms import StringField, PasswordField, BooleanField, SubmitField
  3. from wtforms.validators import ValidationError, DataRequired, Email, EqualTo
  4. from src.app.models import User
  5. class LoginForm(FlaskForm):
  6. username = StringField('Username', validators=[DataRequired()])
  7. password = PasswordField('Password', validators=[DataRequired()])
  8. remember_me = BooleanField('Remember Me')
  9. submit = SubmitField('Sign In')
  10. class RegistrationForm(FlaskForm):
  11. username = StringField('Username', validators=[DataRequired()])
  12. email = StringField('Email', validators=[DataRequired(), Email()])
  13. password = PasswordField('Password', validators=[DataRequired()])
  14. password2 = PasswordField(
  15. 'Repeat Password', validators=[DataRequired(), EqualTo('password')])
  16. submit = SubmitField('Register')
  17. def validate_username(self, username):
  18. user = User.query.filter_by(username=username.data).first()
  19. if user is not None:
  20. raise ValidationError('Please use a different username.')
  21. def validate_email(self, email):
  22. user = User.query.filter_by(email=email.data).first()
  23. if user is not None:
  24. raise ValidationError('Please use a different email address.')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...