当前位置: 首页>>代码示例>>Python>>正文


Python wtforms.PasswordField方法代码示例

本文整理汇总了Python中wtforms.PasswordField方法的典型用法代码示例。如果您正苦于以下问题:Python wtforms.PasswordField方法的具体用法?Python wtforms.PasswordField怎么用?Python wtforms.PasswordField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wtforms的用法示例。


在下文中一共展示了wtforms.PasswordField方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: valid_password

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def valid_password(form: CompleteSignupForm, field: PasswordField) -> None:
    """
    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
    """
    from run import config
    min_pwd_len = int(config['MIN_PWD_LEN'])
    max_pwd_len = int(config['MAX_PWD_LEN'])
    pass_size = len(field.data)
    if pass_size == 0:
        raise ValidationError('new password cannot be empty')
    if pass_size < min_pwd_len or pass_size > max_pwd_len:
        raise ValidationError(
            f'Password needs to be between {min_pwd_len} and {max_pwd_len} characters long (you entered {pass_size})'
        ) 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:21,代码来源:forms.py

示例2: scaffold_form

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def scaffold_form(self):
        form_class = super(UserAdminView, self).scaffold_form()
        form_class.password = PasswordField('Password')
        form_class.new_password = PasswordField('New Password')
        form_class.confirm = PasswordField('Confirm New Password')
        return form_class 
开发者ID:PacktPublishing,项目名称:Flask-Framework-Cookbook-Second-Edition,代码行数:8,代码来源:views.py

示例3: scaffold_form

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def scaffold_form(self):
        form_class = super(UserView, self).scaffold_form()
        form_class.password = PasswordField(
            "Password", [DataRequired(), Length(min=4, max=20)])
        return form_class 
开发者ID:honmaple,项目名称:maple-blog,代码行数:7,代码来源:admin.py

示例4: scaffold_form

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def scaffold_form(self):
        # Start with the standard form as provided by Flask-Admin. We've already told Flask-Admin to exclude the
        # password field from this form.
        form_class = super(UserAdmin, self).scaffold_form()

        # Add a password field, naming it "password2" and labeling it "New Password".
        # autocomplete:new-password is to disable chrome to autofill password
        # Reference: http://stackoverflow.com/questions/15738259/disabling-chrome-autofill
        form_class.password2 = PasswordField(label=lazy_gettext('New Password'),
                                             render_kw={"autocomplete": "new-password"},
                                             description=lazy_gettext('Left blank if you don\'t want to change it, '
                                                                      'input the new password to change it'))
        return form_class 
开发者ID:betterlife,项目名称:betterlifepsi,代码行数:15,代码来源:user.py

示例5: validate_password_repeat

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def validate_password_repeat(form: CompleteSignupForm, field: PasswordField) -> None:
        """
        Validate 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') 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:13,代码来源:forms.py

示例6: validate_current_password

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def validate_current_password(form, field) -> None:
        """
        Validate 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 None:
            raise ValidationError('User instance not passed to form validation')

        if not form.user.is_password_valid(field.data):
            raise ValidationError('Invalid password') 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:16,代码来源:forms.py

示例7: validate_new_password

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def validate_new_password(form, field) -> None:
        """
        Validate 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) 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:15,代码来源:forms.py

示例8: validate_new_password_repeat

# 需要导入模块: import wtforms [as 别名]
# 或者: from wtforms import PasswordField [as 别名]
def validate_new_password_repeat(form, field) -> None:
        """
        Validate 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:
            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') 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:17,代码来源:forms.py


注:本文中的wtforms.PasswordField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。