Exemplo n.º 1
0
class UserRegisterForm(wtf.Form):
    username = wtf.TextField(
        'Username',
        validators=[
            wtf.Required(),
            wtf.Length(min=2, max=50),
            wtf.Regexp(
                '^[a-zA-Z0-9_]*$',
                message=
                ('Username must only contain a to z, 0 to 9, and underscores.'
                 ))
        ],
        description=(
            'Your username is public and used as part of your project name.'))
    email = wtf.TextField('Email',
                          validators=[wtf.Required(),
                                      wtf.validators.Email()])
    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.Length(5),
                                     wtf.EqualTo('confirm',
                                                 'Passwords do not match.'),
                                 ])
    confirm = wtf.PasswordField('Confirm Password')

    def validate_username(form, field):
        from notifico.views.account import _reserved

        username = field.data.strip().lower()
        if username in _reserved or User.username_exists(username):
            raise wtf.ValidationError('Sorry, but that username is taken.')
Exemplo n.º 2
0
class UserPasswordForm(wtf.Form):
    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.Length(5),
                                     wtf.EqualTo('confirm',
                                                 'Passwords do not match.'),
                                 ])
    confirm = wtf.PasswordField('Confirm Password')
Exemplo n.º 3
0
class UserDeleteForm(wtf.Form):
    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.Length(5),
                                     wtf.EqualTo('confirm',
                                                 'Passwords do not match.'),
                                 ])
    confirm = wtf.PasswordField('Confirm Password')

    def validate_password(form, field):
        if not User.login(g.user.username, field.data):
            raise wtf.ValidationError('Password is incorrect.')
Exemplo n.º 4
0
class UserLoginForm(wtf.Form):
    username = wtf.TextField('Username', validators=[wtf.Required()])
    password = wtf.PasswordField('Password', validators=[wtf.Required()])

    def validate_password(form, field):
        if not User.login(form.username.data, field.data):
            raise wtf.ValidationError('Incorrect username and/or password.')
Exemplo n.º 5
0
class PasswordConfirmForm(wtf.Form):
    password = wtf.PasswordField('Password', validators=[wtf.Required()])

    def validate_password(form, field):
        if not User.login(g.user.username, field.data):
            raise wtf.ValidationError('Your password is incorrect.')