python类PasswordField()的实例源码

forms.py 文件源码 项目:sample-platform 作者: CCExtractor 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def validate_current_password(form, field):
        """
        Validates current password entered with the password stored in
        database

        :param form: The form which is being passed in
        :type form: AccountForm
        :param field: The data value for the 'password' entered by User
        :type field : PasswordField
        """
        if form.user is not None:
            if not form.user.is_password_valid(field.data):
                raise ValidationError('Invalid password')
        else:
            raise ValidationError('User instance not passed to form '
                                  'validation')
forms.py 文件源码 项目:sample-platform 作者: CCExtractor 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def validate_new_password_repeat(form, field):
        """
        Validates new password repeat and checks if it matches 'new_password'

        :param form: The form which is being passed in
        :type form: AccountForm
        :param field: The data value for the 'password' entered by User
        :type field : PasswordField
        """
        if form.email is not None:
            # Email form is present, so it's optional
            if len(field.data) == 0 and len(form.new_password.data) == 0:
                return

        if field.data != form.new_password.data:
            raise ValidationError('The password needs to match the new '
                                  'password')
forms.py 文件源码 项目:sample-platform 作者: CCExtractor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def valid_password(form, field):
    """
    Function to check for validity of a password

    :param form: The form which is being passed in
    :type form: Form
    :param field: The data value for the 'password' inserted by User
    :type field : PasswordField
    """
    if len(field.data) == 0:
        raise ValidationError('new password cannot be empty')
    if len(field.data) < 10 or len(field.data) > 500:
        raise ValidationError('Password needs to be between 10 and 500 '
                              'characters long (you entered %s characters'
                              % len(field.data))
forms.py 文件源码 项目:sample-platform 作者: CCExtractor 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def validate_password_repeat(form, field):
        """
        Validates if the repeated password is the same as 'password'

        :param form: The form which is being passed in
        :type form: CompleteSignupForm
        :param field : The data value for the 'password' entered by User
        :type field : PasswordField
        """
        if field.data != form.password.data:
            raise ValidationError('The password needs to match the new '
                                  'password')
forms.py 文件源码 项目:sample-platform 作者: CCExtractor 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def validate_new_password(form, field):
        """
        Validates the new password entered

        :param form: The form which is being passed in
        :type form: AccountForm
        :param field: The data value for the 'password' entered by User
        :type field : PasswordField
        """
        if len(field.data) == 0 and len(form.new_password_repeat.data) == 0:
            return

        valid_password(form, field)
admin.py 文件源码 项目:flask-boilerplate 作者: ItEngine 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def scaffold_form(self):
        form_class = super(UserAdmin, self).scaffold_form()
        form_class.password = PasswordField()
        return form_class


问题


面经


文章

微信
公众号

扫码关注公众号