Can someone explain what in
login_user (force = True)
makes
force = True
?
I didn't find much about it on the Internet.
CodePudding user response:
There's a little note on that in the api docs:
If the user is inactive, setting this to
True
will log them in regardless. Defaults toFalse
.
CodePudding user response:
When confused by the docs, if often helps to read the source. The trick for finding the source is to know to search the Python Package Index (https://pypi.org/), and to navigate from a packages's page to its github (or other) repository. Here, a bit of digging will turn up
https://github.com/maxcountryman/flask-login/blob/main/flask_login/utils.py#L146
which provides the additional clue
Logs a user in. You should pass the actual user object to this. If the
user's `is_active` property is ``False``, they will not be logged in
unless `force` is ``True``.
A bit of exploration through the code shows that AnonymousUserMixin
is used by LoginManager
when no one is logged in, and in that case is_active
will be False
.