Authenticating using the Flask-Login extension
In our previous recipe, we learned how to implement session-based authentication ourselves. Flask-Login
is a popular extension that handles a lot of the same stuff in a helpful and efficient way and thus saves us from reinventing the wheel all over again. In addition, Flask-Login
will not bind us to any specific database or limit us to using any specific fields or methods for authentication. It can also handle the Remember me feature, account recovery features, and so on. In this recipe, we will understand how to use Flask-Login
with our application.
Getting ready
Modify the application created in the previous recipe to accommodate the changes to be done by the Flask-Login
extension.
Before that, we have to install the extension itself with the following command:
$ pip install Flask-Login
How to do it...
Follow these steps to understand how Flask-Login
can be integrated with a Flask application:
- To use
Flask-Login...