From e1e521300b46b8e5979a7cd140b90ff4f04c02e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 7 May 2019 13:11:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Only=20do=20autologin=20if=20not?= =?UTF-8?q?=20actively=20logged=20out?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3142 --- src/octoprint/server/api/__init__.py | 11 +++++++++-- src/octoprint/server/util/flask.py | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/octoprint/server/api/__init__.py b/src/octoprint/server/api/__init__.py index dbcdaa6ef..a330e1ecb 100644 --- a/src/octoprint/server/api/__init__.py +++ b/src/octoprint/server/api/__init__.py @@ -236,7 +236,10 @@ def login(): response["_is_external_client"] = s().getBoolean(["server", "ipCheck", "enabled"]) \ and not util_net.is_lan_address(remote_addr, additional_private=s().get(["server", "ipCheck", "trustedSubnets"])) - return jsonify(response) + + r = make_response(jsonify(response)) + r.delete_cookie("active_logout") + return r return make_response(("User unknown or password incorrect", 401, [])) @@ -254,7 +257,11 @@ def logout(): # ... and from flask login (and principal) logout_user() - return NO_CONTENT + # ... and send an active logout session cookie + r = make_response(NO_CONTENT) + r.set_cookie("active_logout", "true") + + return r def _logout(user): diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 62f8905bf..93f68802c 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -584,7 +584,8 @@ def passive_login(): elif settings().getBoolean(["accessControl", "autologinLocal"]) \ and settings().get(["accessControl", "autologinAs"]) is not None \ - and settings().get(["accessControl", "localNetworks"]) is not None: + and settings().get(["accessControl", "localNetworks"]) is not None \ + and not "active_logout" in flask.request.cookies: autologin_as = settings().get(["accessControl", "autologinAs"]) local_networks = _local_networks()