예제 #1
0
class ResetPasswordEmailAccessForm(EmailForm):
    authcode = HiddenField('验证码')
    password = PasswordField(
        '新密码',
        validators=[
            DataRequired(),
            Length(min=6, max=18),
            Regexp(r"""^[\w\d\-\[\]{}|\\,.\/<>;:'"_`~!@#$%^&*()+= ]+$""",
                   message='密码只能包含英文字符,数字或其他可见符号'),
        ])
    repassword = PasswordField('确认密码', validators=[DataRequired()])
예제 #2
0
class LoginForm(Form):
    """ 用户登录 """

    account = TextField('邮箱/手机',
                        validators=[
                            Strip(),
                            Lower(),
                            DataRequired(),
                        ])
    password = PasswordField('密码', validators=[DataRequired()])
    remember = BooleanField('记住登录状态')
예제 #3
0
class LoginForm(Form):
    account = TextField('用户名/邮箱/手机',
                        validators=[Strip(), Lower(), DataRequired()])
    password = PasswordField('密码', validators=[])
    remember = BooleanField('记住登录状态')

    def validate_account(self, field):
        admin = AdminUser.objects(
            username=self.account.data).first()
        if not admin:
            raise ValueError('用户不存在')
        if not admin.active:
            raise ValueError('用户被冻结')
        if admin.password != self.password.data:
            AdminUserLoginLog.error(admin.id)
            count = AdminUserLoginLog.objects(
                created__gte=max(today(), admin.freezed or today()),
                user=admin.id,
                type=AdminUserLoginLog.TYPE.ERROR).count()
            if count >= 20:
                admin.active = False
                admin.freezed = datetime.now()
                admin.save()
            raise ValueError('密码错误')

        self.admin = admin
예제 #4
0
class PhoneForm(Form):
    """ 手机注册、绑定、重置密码 """

    phone = TextField('手机',
                      validators=[
                          Strip(),
                          DataRequired(),
                          Regexp(r"""^1\d{10}$""", message='手机号码不正确'),
                      ])
    authcode = TextField('手机验证码')
    password = PasswordField(
        '密码',
        validators=[
            DataRequired(),
            Length(min=6, max=18),
            Regexp(r"""^[\w\d\-\[\]{}|\\,.\/<>;:'"_`~!@#$%^&*()+= ]+$""",
                   message='密码只能包含英文字符,数字或其他可见符号'),
        ])
예제 #5
0
class RegisterPhoneForm(PhoneForm):
    verify_code = VerifyCodeField('验证码', key='users_register_phone')
    password = PasswordField(
        '密码',
        validators=[
            DataRequired(),
            Length(min=6, max=18),
            Regexp(r"""^[\w\d\-\[\]{}|\\,.\/<>;:'"_`~!@#$%^&*()+= ]+$""",
                   message='密码只能包含英文字符,数字或其他可见符号'),
        ],
    )
예제 #6
0
class BindPhoneForm(PhoneForm):
    verify_code = VerifyCodeField('验证码', key='users_bind_phone')
    repassword = PasswordField('确认密码', validators=[DataRequired()])