Split the Flask-Login login manager initialization from the init_app method to the __init_login_manager method in the DigestAuth class, to simplify the code.

This commit is contained in:
依瑪貓 2023-04-29 11:17:11 +08:00
parent 919b8d0dc3
commit 5b255b6504

View File

@ -344,8 +344,15 @@ class DigestAuth:
self.realm = app.config["DIGEST_AUTH_REALM"]
if hasattr(app, "login_manager"):
from flask_login import LoginManager, login_user
self.__init_login_manager(app)
def __init_login_manager(self, app: Flask) -> None:
"""Initializes the Flask-Login login manager.
:param app: The Flask application.
:return: None.
"""
from flask_login import LoginManager, login_user
login_manager: LoginManager = getattr(app, "login_manager")
@login_manager.unauthorized_handler