🐛 Fix potential race condition

Static assets where being sent with session cookies. That doesn't make
sense and might actually cause issues if an asset takes *just* long
enough to load to be overtaken by a login request from something like
the loginui.

Found with the E2E tests, which turned out to be less flaky themselves
than thought 🥳
This commit is contained in:
Gina Häußge committed 2020-07-14 17:43:01 +02:00
1 parent 01940bbb10
commit 7d037ab1a4
1 file changed
+4
+4
View File
@@ -10,6 +10,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
import tornado.web
import flask
import flask.json
import flask.sessions
import flask_login
import octoprint.vendor.flask_principal as flask_principal
import flask_assets
@@ -531,6 +532,9 @@ class OctoPrintFlaskResponse(flask.Response):
class OctoPrintSessionInterface(flask.sessions.SecureCookieSessionInterface):
def should_set_cookie(self, app, session):
return flask.request.endpoint != "static"
def save_session(self, app, session, response):
if flask.g.get("login_via_apikey", False):
return