Python django.contrib.auth.password_validation 模块,password_validators_help_text_html() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用django.contrib.auth.password_validation.password_validators_help_text_html()

项目:rho-django-user    作者:freakboy3742    | 项目源码 | 文件源码
def password_validators_help_text_html(self):
            return None
项目:django-register-activate    作者:JunyiJ    | 项目源码 | 文件源码
def clean(self):
        #rewriting clean method to check whether passwords match or not
        cleaned_data=super(SignupForm,self).clean()
        username=cleaned_data.get('username')
        email=cleaned_data.get('email')
        ps1=cleaned_data.get('password')
        ps2=cleaned_data.get('verify_password')
        if email=="":
            self.add_error('email',"Please input your email!")
        if ps1!=ps2:
            msg="Password does not match!"
            self.add_error('verify_password',msg)
        # Save hashed password instead of password directly
        encoded_password=make_password(ps1,make_salt())
        cleaned_data['password']=encoded_password
        # Make sure email is unique
        if email and User.objects.filter(email=email).exclude(username=username).count():
            msg="Email has been used!"
            self.add_error('email',msg)
        # Validate password
        if ps1:
            try:
                validate_password(ps1,user=self)
                cleaned_data['help_text']=None
            except ValidationError:
                cleaned_data['help_text']=password_validators_help_text_html()
                self.add_error('password','Your password it too weak. Please choose another password')
        return cleaned_data