ashutoshkrris / Flask-User-Authentication

User authentication is important for protecting sensitive information and resources from unauthorized access. In this tutorial, you will learn how to set up basic user authentication – that is password-based authentication – in your Flask application.
https://ashutoshkrris.hashnode.dev/how-to-set-up-basic-user-authentication-in-a-flask-app
34 stars 26 forks source link

issue with Flask_wtf (resolved) #4

Open sylvain471 opened 10 months ago

sylvain471 commented 10 months ago

Hi, thanks for this very nice repo.

I couldn't install the requirements using pip install -r requirements.txt my terminal threw some errors that I couldn't resolve.

I installed all packages regardless of the version number given in the requirements.txt.

I ran the steps mentioned in a previous issue

flask db init 
...

When I started the app I tried to sign up and the following issue came up

TypeError: validate() got an unexpected keyword argument 'extra_validators'

Finding the form.py file in the flask_wtf package directory and changing the method validate_on_submit

    def validate_on_submit(self, extra_validators=None):
        """Call :meth:`validate` only if the form is submitted.
        This is a shortcut for ``form.is_submitted() and form.validate()``.
        """
        #return self.is_submitted() and self.validate(extra_validators=extra_validators)
        return self.is_submitted() and self.validate()

ie removing extra_validator from validate, solved the problem.

ashutoshkrris commented 10 months ago

Thanks for pointing out the issue, @sylvain471 Looks like there might be some update in the latest flask wtf package.

guywiz commented 10 months ago

I came upon the same problem. Editing the RegisterForm class seems to overcome this problem (the idea came after looking at the source code of the FlaskForm class). I added the extra_validators keyword parameter to: form.RegisterForm.validate_on_submit and adjusted the call to the mother class (FlaskForm) method self.validate(extra_validators). I pushed these changes on my forked version of the repo, in case this solution seems acceptable.