remove unnecessary shit

pull/108/head
Aevann 2023-02-01 21:05:39 +02:00
parent b7e4f27f65
commit c09ca02a1e
1 changed files with 0 additions and 15 deletions

View File

@ -51,7 +51,6 @@ def before_request():
@app.after_request
def after_request(response:Response):
if response.status_code < 400:
_set_cloudflare_cookie(response)
_commit_and_close_db()
return response
@ -62,20 +61,6 @@ def teardown_request(error):
_rollback_and_close_db()
stdout.flush()
def _set_cloudflare_cookie(response:Response) -> None:
'''
Sets a cookie that can be used by an upstream DDoS protection and caching provider
'''
if not g.desires_auth: return
if not CLOUDFLARE_AVAILABLE or not CLOUDFLARE_COOKIE_VALUE: return
logged_in = bool(getattr(g, 'v', None))
if not logged_in and request.cookies.get("lo"):
response.delete_cookie("lo", domain=app.config["COOKIE_DOMAIN"], samesite="Lax")
elif logged_in and not request.cookies.get("lo"):
response.set_cookie("lo", CLOUDFLARE_COOKIE_VALUE if logged_in else '',
max_age=SESSION_LIFETIME, samesite="Lax",
domain=app.config["COOKIE_DOMAIN"])
def _commit_and_close_db() -> bool:
if not getattr(g, 'db', None): return False
g.db.commit()