A simple web application that allows invitation based registration to a matrix instance
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

40 lines
1.5 KiB

from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, DateField, IntegerField, SubmitField
from wtforms.validators import DataRequired, Length, EqualTo, InputRequired, \
ValidationError, NumberRange, Optional
import safe
def safe_password_validator(form: FlaskForm, field):
strength = safe.check(field.data, level=safe.MEDIUM)
if not strength.valid:
raise ValidationError("Password is not secure enough: %s" % strength.message)
class RegistrationForm(FlaskForm):
username = StringField('Username', validators=[DataRequired(), Length(min=3, max=30)])
password = PasswordField(
'Password',
validators=[
InputRequired(),
EqualTo('confirm', message='Passwords must match'),
safe_password_validator
])
confirm = PasswordField('Repeat Password')
registration_code = StringField('Registration Code', validators=[DataRequired()])
class LoginForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
token = PasswordField('Token', validators=[DataRequired()])
class RegistrationCodeForm(FlaskForm):
expiration_time = DateField('Expiration Time', validators=[Optional()])
max_usages = IntegerField('Max Usages', validators=[NumberRange(min=1)])
class ExpireRegistrationCodeForm(FlaskForm):
registration_code = StringField('Registration Code')
expire = SubmitField(label='Expire')
delete = SubmitField(label='Delete')