Flask-Login is a popular Flask extension for handling the process of logging users in and out, properly handling cookie sessions, and even using basic authentication with HTTP headers. It will set up callbacks for user loading, header authentication, logging in, logging out, unauthorized events, and so on.
To start using Flask-Login, we first need to declare it as a dependency on our requirements.txt, as shown in the following code:
...
Flask-Login
...
Then, we need to update our Python virtual environment as follows:
$ source venv/bin/activate
$ pip install -r requirements.txt
If you have executed the provided init.sh script, then there is no need to update the virtualenv. All the required dependencies for this chapter are already installed.
To use the session and login flow implemented by Flask-Login, we will need to do the following:
- Change the user model...