Ejemplo n.º 1
0
class AddUser(Form):
    username = StringField('Username', [validators.DataRequired()])
    email = StringField('Email', [validators.DataRequired(), validators.Email()])
    password = PasswordField('New Password', [
        validators.DataRequired(),
        validators.EqualTo('confirm', message='Passwords must match')
    ])
    confirm = PasswordField('Repeat Password')
    adminuser = BooleanField('Admin?')
Ejemplo n.º 2
0
class LoginForm(Form):
    """This class renders the form's username and password which is needed for the user to sign in"""

    email = StringField(
        'Email address',
        [validators.DataRequired(),
         validators.length(min=4, max=80)])
    password = PasswordField("Password",
                             validators=[
                                 validators.DataRequired(),
                                 validators.length(min=8, max=80)
                             ])
Ejemplo n.º 3
0
class PasswordResetForm(FlaskForm):
    username = StringField('username', validators=[DataRequired()])
    new_password = PasswordField('new_password', [
        validators.DataRequired(),
        validators.EqualTo('verify_new_password',
                           message='Passwords must match')
    ])
    verify_new_password = PasswordField('verify_new_password')
    token = StringField('token', validators=[DataRequired()])

    if RECAPTCHA is True:
        recaptcha = RecaptchaField('recaptcha')

    def __init__(self, *args, **kwargs):
        FlaskForm.__init__(self, *args, **kwargs)
        self.user = None

    def validate(self):
        rv = FlaskForm.validate(self)
        if not rv:
            return False

        user = User.query.filter_by(username=self.username.data).first()
        if user is None:
            self.username.errors.append('Unknown username')
            return False

        self.user = user
        return True
Ejemplo n.º 4
0
class EditUser(Form):
    username = StringField('Username')
    email = StringField('Email', [validators.Email()])
    oldpassword = PasswordField('Old Password')
    password = PasswordField('New Password', [
        validators.DataRequired(),
        validators.EqualTo('confirm', message='Passwords must match')])
    confirm = PasswordField('Repeat Password')
Ejemplo n.º 5
0
class RegistrationForm(Form):

    login = StringField(
        'Login', [validators.Length(min=4, max=25),
                  validators.DataRequired()])

    password = PasswordField('Password', [
        validators.DataRequired(),
        validators.EqualTo('verification', message='Passwords must match')
    ])

    full_name = StringField('Full name', [validators.DataRequired()])

    verification = PasswordField('Repeat password',
                                 [validators.DataRequired()])

    email = StringField('Email', [
        validators.Length(min=6, max=35),
        validators.Email(),
        validators.DataRequired()
    ])
Ejemplo n.º 6
0
class PasswordChangeForm(FlaskForm):
    current_password = PasswordField('current_password',
                                     validators=[DataRequired()])
    new_password = PasswordField('new_password', [
        validators.DataRequired(),
        validators.EqualTo('verify_new_password',
                           message='Passwords must match')
    ])

    verify_new_password = PasswordField('verify_new_password',
                                        validators=[DataRequired()])

    def __init__(self, *args, **kwargs):
        FlaskForm.__init__(self, *args, **kwargs)
        self.user = None

    def validate(self):
        rv = FlaskForm.validate(self)
        if not rv:
            return False

        user = User.query.filter_by(username=current_user.username).first()

        if user is None:
            self.current_password.errors.append('Unknown user')
            return False
        print(self.current_password)
        print(self.new_password)
        if self.current_password.data == self.new_password:
            self.current_password.errors.append(
                'New password must be different then old one!')
            return False

        if not check_password_hash(user.password, self.current_password.data):
            self.current_password.errors.append('Invalid current password!')
            return False

        self.user = user
        return True
Ejemplo n.º 7
0
class LoginForm(Form):
    username = StringField('username', [validators.DataRequired()])
    password = PasswordField('password', [validators.DataRequired()])