Exemplo n.º 1
0
class ExtendedResetPasswordForm(ResetPasswordForm):
    password = PasswordField("",
                             validators=[
                                 password_required, password_length,
                                 EqualTo('password_confirm',
                                         message='RETYPE_PASSWORD_MISMATCH')
                             ])
    password_confirm = PasswordField(
        "",
        validators=[
            password_required, password_length,
            EqualTo('password', message='RETYPE_PASSWORD_MISMATCH')
        ])
    submit = SubmitField("Obnovit heslo")
Exemplo n.º 2
0
class PasswordConfirmFormMixin():
    password_confirm = PasswordField(
        get_form_field_label('retype_password'),
        validators=[
            EqualTo('password', message='RETYPE_PASSWORD_MISMATCH'),
            password_required
        ])
Exemplo n.º 3
0
class ExtendedPasswordChangeForm(ChangePasswordForm):
    password = PasswordField("", validators=[password_required])
    new_password = PasswordField("",
                                 validators=[
                                     password_required, password_length,
                                     EqualTo(
                                         'new_password_confirm',
                                         message='RETYPE_PASSWORD_MISMATCH')
                                 ])
    new_password_confirm = PasswordField(
        "",
        validators=[
            password_required, password_length,
            EqualTo('new_password', message='RETYPE_PASSWORD_MISMATCH')
        ])
    submit = SubmitField("Změnit heslo")
Exemplo n.º 4
0
class ChangePasswordForm(Form, PasswordFormMixin):
    """The default change password form"""

    new_password = PasswordField(
        get_form_field_label('new_password'),
        validators=[password_required, password_length,
                    PasswordPolicy()])

    new_password_confirm = PasswordField(
        get_form_field_label('retype_password'),
        validators=[
            EqualTo('new_password', message='RETYPE_PASSWORD_MISMATCH'),
            password_required
        ])

    submit = SubmitField(get_form_field_label('change_password'))

    def validate(self):
        if not super(ChangePasswordForm, self).validate():
            return False

        if not verify_and_update_password(self.password.data, current_user):
            self.password.errors.append(get_message('INVALID_PASSWORD')[0])
            return False
        if self.password.data.strip() == self.new_password.data.strip():
            self.password.errors.append(get_message('PASSWORD_IS_THE_SAME')[0])
            return False
        return True
Exemplo n.º 5
0
class OyChangePasswordForm(Form):
    old_password = PasswordField(
        label=lazy_gettext("Old Password"),
        validators=[password_required],
        render_kw=dict(required=True),
    )
    password = PasswordField(
        label=lazy_gettext("Password"),
        description=lazy_gettext("Not less than 6 characters"),
        validators=[password_required, password_length],
        render_kw=dict(required=True),
    )
    password_confirm = PasswordField(
        label=lazy_gettext("Re-Type Password"),
        validators=[EqualTo("password", message="RETYPE_PASSWORD_MISMATCH")],
        render_kw=dict(required=True),
    )

    def __init__(self, user, *args, **kwargs):
        self.user = user
        super(OyChangePasswordForm, self).__init__(*args, **kwargs)

    def validate(self):
        if not super(OyChangePasswordForm, self).validate():
            return False
        if not verify_and_update_password(self.old_password.data, self.user):
            self.old_password.errors.append(gettext("Incorrect Password"))
            return False
        if self.old_password.data.strip() == self.password.data.strip():
            self.password.errors.append(
                gettext("The new password is the same as the old password")
            )
            return False
        return True
Exemplo n.º 6
0
    def get_create_form(self):
        CreateForm = super().get_create_form()

        CreateForm.email = html5.EmailField(
            'Email',
            validators=[
                validators.DataRequired(),
                validators.Email(),
                unique_user_email,
            ],
        )
        CreateForm.password = fields.PasswordField(
            'Password',
            validators=[
                validators.DataRequired(),
                password_length,
            ],
        )
        CreateForm.confirm_password = fields.PasswordField(
            'Confirm Password',
            validators=[
                validators.DataRequired(),
                EqualTo('password', message='RETYPE_PASSWORD_MISMATCH'),
            ],
        )

        CreateForm.field_order = ('username', 'email', 'first_name',
                                  'last_name', 'password', 'confirm_password',
                                  'roles', 'active')

        return CreateForm
Exemplo n.º 7
0
class RegisterForm(ConfirmRegisterForm, NextFormMixin):
    password_confirm = PasswordField(
        get_form_field_label("retype_password"),
        validators=[
            EqualTo("password", message="RETYPE_PASSWORD_MISMATCH"),
            validators.Optional(),
        ],
    )

    csrf_token = uuid.uuid4()

    def validate(self):
        if not super(RegisterForm, self).validate():
            return False

        if not config_value("UNIFIED_SIGNIN"):
            # password_confirm required
            if not self.password_confirm.data or not self.password_confirm.data.strip(
            ):
                self.password_confirm.errors.append(
                    get_message("PASSWORD_NOT_PROVIDED")[0])
                return False

        return True

    def __init__(self, *args, **kwargs):
        super(RegisterForm, self).__init__(*args, **kwargs)
        if not self.next.data:
            self.next.data = request.args.get("next", "")
Exemplo n.º 8
0
class PasswordConfirmFormMixin:
    password_confirm = PasswordField(
        get_form_field_label("retype_password"),
        validators=[
            EqualTo("password", message="RETYPE_PASSWORD_MISMATCH"),
            password_required,
        ],
    )
Exemplo n.º 9
0
class PasswordConfirmFormMixin():

    password_confirm = PasswordField(
        get_form_field_label('retype_password'),
        validators=[
            OptionalIf('random_password'),
            EqualTo('password', message='RETYPE_PASSWORD_MISMATCH')
        ])
Exemplo n.º 10
0
class ChangePasswordFormMixin(object):
    newPassword = PasswordField(
        'New Password', validators=[password_required, password_length])

    confirmNewPassword = PasswordField(
        'Confirm New Password',
        validators=[
            password_required,
            EqualTo('newPassword', message='RETYPE_PASSWORD_MISMATCH')
        ])
Exemplo n.º 11
0
class AddUserForm(Form):
    username = StringField('Username',
                           [validators.required(message='Enter a user name')])
    password = PasswordField(
        'Password',
        [Required(),
         EqualTo('confirm', message='Passwords must match')])
    confirm = PasswordField('Repeat Password')
    roles = SelectField('Roles', choices=[])
    email = StringField(
        'Email', [validators.DataRequired("Please enter your email address.")])
Exemplo n.º 12
0
class NOIResetPasswordForm(ResetPasswordForm):
    '''
    Localizeable ResetPasswordForm
    '''

    submit = SubmitField(lazy_gettext('Reset Password'))
    password = PasswordField(lazy_gettext('Password'),
                             validators=[password_required, password_length])
    password_confirm = PasswordField(
        lazy_gettext('Retype Password'),
        validators=[EqualTo('password', message='RETYPE_PASSWORD_MISMATCH')])
Exemplo n.º 13
0
class NewPasswordConfirmMixin(object):
    password = PasswordField(
        label=lazy_gettext('Password'),
        description=lazy_gettext('Not less than 6 characters'),
        validators=[password_required, password_length],
        render_kw=dict(required=True)
    )
    password_confirm = PasswordField(
        label=lazy_gettext('Re-Type Password'),
        validators=[EqualTo('password', message='RETYPE_PASSWORD_MISMATCH')],
        render_kw=dict(required=True)
    )
Exemplo n.º 14
0
class ExtendedRegisterForm(RegisterForm):
    name = StringField(
        '名字', validators=[name_required, name_length, unique_user_name])
    email = StringField(
        '邮箱', validators=[email_required, email_validator, unique_user_email])
    password = PasswordField('密码', validators=[password_required])
    password_confirm = PasswordField(
        '密码确认',
        validators=[
            EqualTo('password', message='RETYPE_PASSWORD_MISMATCH'),
            password_required
        ])
Exemplo n.º 15
0
class ExtendedRegisterForm(RegisterForm):
    name = StringField(
        "名字", validators=[name_required, name_length, unique_user_name])
    email = StringField(
        "邮箱", validators=[email_required, email_validator, unique_user_email])
    password = PasswordField("密码", validators=[password_required])
    password_confirm = PasswordField(
        "确认密码",
        validators=[
            EqualTo("password", message="RETYPE_PASSWORD_MISMATCH"),
            password_required,
        ],
    )
Exemplo n.º 16
0
class NOIChangePasswordForm(ChangePasswordForm):
    '''
    Localizeable ChangePasswordForm
    '''

    password = PasswordField(lazy_gettext('Password'),
                             validators=[password_required])

    new_password = PasswordField(
        lazy_gettext('New Password'),
        validators=[password_required, password_length])

    new_password_confirm = PasswordField(
        lazy_gettext('Retype Password'),
        validators=[
            EqualTo('new_password', message='RETYPE_PASSWORD_MISMATCH')
        ])

    submit = SubmitField(lazy_gettext('Change Password'))
Exemplo n.º 17
0
class OyRegisterForm(RegisterForm):
    user_name = StringField(
        label=lazy_gettext("User Name"),
        description=lazy_gettext("Should be UNIQUE"),
        validators=[data_required(), unique_username],
        render_kw=dict(required=True),
    )
    email = EmailField(
        label=lazy_gettext("User Email"),
        description=lazy_gettext(
            "An active email address, a confirmation link will be sent to it."
        ),
        validators=[email_required, email_validator, unique_user_email],
        render_kw=dict(required=True),
    )
    password = PasswordField(
        label=lazy_gettext("Password"),
        description=lazy_gettext("Not less than 6 characters"),
        validators=[password_required, password_length],
        render_kw=dict(required=True),
    )
    password_confirm = PasswordField(
        label=lazy_gettext("Re-Type Password"),
        validators=[EqualTo("password", message="RETYPE_PASSWORD_MISMATCH")],
        render_kw=dict(required=True),
    )
    roles = QuerySelectMultipleField(
        label=lazy_gettext("User Roles"),
        allow_blank=True,
        blank_text=lazy_gettext("No Roles"),
        query_factory=lambda: Role.query,
    )
    send_confirmation = BooleanField(
        label=lazy_gettext("Require email confirmation"),
        description=lazy_gettext(
            "we will not activate this account untill the user confirms his/her email address"
        ),
        default=True,
    )