- Make sure you have
SECRET_KEY
in your.env
file- Flask-Login uses sessions for authentication, secret key is used to encrypting the cookies in session, the user could look at the contents of cookie but not modify it, unless they know the secret key used for signing.
- Initializing Flask-Login in your
app.py
or__init__.py
- A user loader tells Flask-Login how to get a specific user object from the ID that is stored in the session cookie
from flask_login import LoginManager from models.user import User
login_manager = LoginManager()