Skip to content

Commit

Permalink
Merge pull request #2905 from andrewbaldwin44/bugfix/login-manager-er…
Browse files Browse the repository at this point in the history
…rors

Fix Login Manager Error Message
  • Loading branch information
cyberw authored Sep 17, 2024
2 parents bf797b8 + 4f6e8ce commit 3762075
Showing 1 changed file with 10 additions and 4 deletions.
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

0 comments on commit 3762075

Please sign in to comment.