-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
executable file
Β·25 lines (21 loc) Β· 1.07 KB
/
forms.py
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
from flask_wtf import FlaskForm
from Database.models import Fcuser
from wtforms import StringField, PasswordField
from wtforms.validators import DataRequired, EqualTo
class RegisterForm(FlaskForm):
userid = StringField('userid', validators=[DataRequired()])
username = StringField('username', validators=[DataRequired()])
password = PasswordField('password', validators=[DataRequired(), EqualTo('re_password')])
re_password = PasswordField('re_password', validators=[DataRequired()])
class LoginForm(FlaskForm):
class UserPassword(object):
def __init__(self, message=None):
self.message = message
def __call__(self, form, field):
userid = form['userid'].data
password = field.data
fcuser = Fcuser.query.filter_by(userid=userid).first()
if fcuser.password != password:
raise ValueError('Wrong password')
userid = StringField('userid', validators=[DataRequired()])
password = PasswordField('password', validators=[DataRequired(), UserPassword()])