lala
lala

Reputation: 1

Stop displaying help text from custom password validator using django allauth

I am trying to make a custom password validator and I got a problem where the HTML page renders return string from get_help_text(). I found that the help text is being displayed before I enter a password for the signup page, and it is still there after ValidationError occurs due to invalid input

I don't have any html file for the sign up page and I'm seeing the default UI provided by allauth. enter image description here

This is my validators.py

class CustomPasswordValidator:
    def validate(self, password, user=None):
        if (
                len(password) < 8 or
                not contains_uppercase_letter(password) or
                not contains_lowercase_letter(password) or
                not contains_number(password) or
                not contains_special_character(password)
        ):
            raise ValidationError("Password must be at least 8 chracters that are a combination of uppercase letter, lowercase letter, numbers and special characters.")

    def get_help_text(self):
        return "Enter at least 8 characters that are a combination of uppercase letter, lowercase letter, numbers and special characters."
        

def validate_no_special_characters(value):
    if contains_special_character(value):
        raise ValidationError("Cannot contain special characters.")

and this is a part of my settings.py

AUTH_PASSWORD_VALIDATORS = [
    {
      "NAME":"appname.validators.CustomPasswordValidator",
    },
]
...

ACCOUNT_PASSWORD_INPUT_RENDER_VALUE = True

I tried returning empty string in get_help_text() but the html page displayed ul list with no content. I don't even want the list on the html page. How can I do this? enter image description here

Upvotes: 0

Views: 30

Answers (0)

Related Questions