Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Login Manager Error Message #2905

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ def __init__(
# ensures static js files work on Windows
mimetypes.add_type("application/javascript", ".js")

if self.web_login:
self._login_manager = LoginManager()
self._login_manager.init_app(self.app)
self._login_manager.login_view = "login"

if environment.runner:
self.update_template_args()
if not delayed_start:
Expand Down Expand Up @@ -516,13 +521,14 @@ def update_user():
@property
def login_manager(self):
if self.web_login:
login_manager = LoginManager()
login_manager.init_app(self.app)
login_manager.login_view = "login"
return login_manager
return self._login_manager

raise AttributeError("The login_manager is only available with --web-login.\n")

@login_manager.setter
def login_manager(self, value):
self._login_manager = value

def start(self):
self.greenlet = gevent.spawn(self.start_server)
self.greenlet.link_exception(greenlet_exception_handler)
Expand Down
Loading