|
|
@ -1,6 +1,7 @@ |
|
|
|
from flask_wtf import FlaskForm |
|
|
|
from flask_wtf import FlaskForm |
|
|
|
from wtforms import StringField, PasswordField, SubmitField, BooleanField |
|
|
|
from wtforms import StringField, PasswordField, SubmitField, BooleanField |
|
|
|
from wtforms.validators import DataRequired, EqualTo, ValidationError, Length |
|
|
|
from wtforms.validators import DataRequired, EqualTo, ValidationError, Length |
|
|
|
|
|
|
|
from wtforms_validators import NotEqualTo |
|
|
|
from app.models import User |
|
|
|
from app.models import User |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -14,7 +15,7 @@ class RegistrationForm(FlaskForm): |
|
|
|
username = StringField('Username', validators=[DataRequired(), Length(min=0, max=64)]) |
|
|
|
username = StringField('Username', validators=[DataRequired(), Length(min=0, max=64)]) |
|
|
|
password = PasswordField('Password', validators=[DataRequired(), Length(min=0, max=128)]) |
|
|
|
password = PasswordField('Password', validators=[DataRequired(), Length(min=0, max=128)]) |
|
|
|
password2 = PasswordField( |
|
|
|
password2 = PasswordField( |
|
|
|
'Repeat Password', validators=[DataRequired(), EqualTo('password')]) |
|
|
|
'Repeat Password', validators=[DataRequired(), EqualTo('password', 'Field must be equal to Password')]) |
|
|
|
submit = SubmitField('Register') |
|
|
|
submit = SubmitField('Register') |
|
|
|
|
|
|
|
|
|
|
|
def validate_username(self, username): |
|
|
|
def validate_username(self, username): |
|
|
@ -23,17 +24,18 @@ class RegistrationForm(FlaskForm): |
|
|
|
raise ValidationError('Please use a different username.') |
|
|
|
raise ValidationError('Please use a different username.') |
|
|
|
|
|
|
|
|
|
|
|
class ChangePasswordForm(FlaskForm): |
|
|
|
class ChangePasswordForm(FlaskForm): |
|
|
|
old_password = PasswordField('Old Password', validators=[DataRequired(), |
|
|
|
old_password = PasswordField('Old Password', |
|
|
|
Length(min=0, max=128)]) |
|
|
|
validators=[DataRequired(), Length(min=0, max=128)]) |
|
|
|
new_password = PasswordField('New Password', validators=[DataRequired(), |
|
|
|
new_password = PasswordField('New Password', |
|
|
|
Length(min=0, max=128)]) |
|
|
|
validators=[DataRequired(), Length(min=0, max=128), |
|
|
|
|
|
|
|
NotEqualTo('old_password', 'Please choose a new password')]) |
|
|
|
new_password2 = PasswordField( |
|
|
|
new_password2 = PasswordField( |
|
|
|
'Repeat New Password', validators=[DataRequired(), EqualTo('new_password')]) |
|
|
|
'Repeat New Password', validators=[DataRequired(), EqualTo('new_password', 'Field must be equal to New Password')]) |
|
|
|
submit = SubmitField('Apply') |
|
|
|
submit = SubmitField('Apply') |
|
|
|
|
|
|
|
|
|
|
|
class SetPasswordForm(FlaskForm): |
|
|
|
class SetPasswordForm(FlaskForm): |
|
|
|
new_password = PasswordField('New Password', validators=[DataRequired(), |
|
|
|
new_password = PasswordField('New Password', validators=[DataRequired(), |
|
|
|
Length(min=0, max=128)]) |
|
|
|
Length(min=0, max=128)]) |
|
|
|
new_password2 = PasswordField( |
|
|
|
new_password2 = PasswordField( |
|
|
|
'Repeat New Password', validators=[DataRequired(), EqualTo('new_password')]) |
|
|
|
'Repeat New Password', validators=[DataRequired(), EqualTo('new_password', 'Field must be equal to New Password')]) |
|
|
|
submit = SubmitField('Set Password') |
|
|
|
submit = SubmitField('Set Password') |
|
|
|