@@ -101,6 +101,16 @@ <h1 class="title">Module <code>supertokens_python.framework.flask.flask_middlewa
101101
102102 return response_.response
103103
104+ @app.teardown_request
105+ def _(_):
106+ from flask import g
107+
108+ if hasattr(g, "supertokens"):
109+ # this is to ensure there are no shared objects between requests.
110+ # calling any other API with a shared request causes a security issue, resulting in unintentional
111+ # sign-ins. More on this here - https://github.com/supertokens/supertokens-python/issues/463
112+ g.pop("supertokens")
113+
104114 def set_error_handler(self):
105115 app = self.app
106116 from supertokens_python.exceptions import SuperTokensError
@@ -203,6 +213,16 @@ <h2 class="section-title" id="header-classes">Classes</h2>
203213
204214 return response_.response
205215
216+ @app.teardown_request
217+ def _(_):
218+ from flask import g
219+
220+ if hasattr(g, "supertokens"):
221+ # this is to ensure there are no shared objects between requests.
222+ # calling any other API with a shared request causes a security issue, resulting in unintentional
223+ # sign-ins. More on this here - https://github.com/supertokens/supertokens-python/issues/463
224+ g.pop("supertokens")
225+
206226 def set_error_handler(self):
207227 app = self.app
208228 from supertokens_python.exceptions import SuperTokensError
@@ -288,7 +308,17 @@ <h3>Methods</h3>
288308 if hasattr(g, "supertokens") and g.supertokens is not None:
289309 manage_session_post_response(g.supertokens, response_, {})
290310
291- return response_.response</ code > </ pre >
311+ return response_.response
312+
313+ @app.teardown_request
314+ def _(_):
315+ from flask import g
316+
317+ if hasattr(g, "supertokens"):
318+ # this is to ensure there are no shared objects between requests.
319+ # calling any other API with a shared request causes a security issue, resulting in unintentional
320+ # sign-ins. More on this here - https://github.com/supertokens/supertokens-python/issues/463
321+ g.pop("supertokens")</ code > </ pre >
292322</ details >
293323</ dd >
294324< dt id ="supertokens_python.framework.flask.flask_middleware.Middleware.set_error_handler "> < code class ="name flex ">
0 commit comments