Skip to content

Commit

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

Add Error Message for Accessing Login Manager without --web-login
  • Loading branch information
cyberw authored Sep 13, 2024
2 parents 4120e5b + 1f4fcc9 commit 54f30cd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ 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(app)
self.login_manager.login_view = "login"

if environment.runner:
self.update_template_args()
if not delayed_start:
Expand Down Expand Up @@ -518,6 +513,16 @@ def update_user():

return {}, 201

@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

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

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

0 comments on commit 54f30cd

Please sign in to comment.