當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。