forked from MarseyWorld/MarseyWorld
Add logged_out redirect (#227)
parent
8c25a48d0c
commit
5d6885e5bf
|
@ -16,6 +16,24 @@ def rdrama(id, title):
|
|||
id = ''.join(f'{x}/' for x in id)
|
||||
return redirect(f'/archives/drama/comments/{id}{title}.html')
|
||||
|
||||
@app.get('/logged_out/')
|
||||
@app.get('/logged_out/<path:old>')
|
||||
def logged_out(old = ""):
|
||||
# Remove trailing question mark from request.full_path which flask adds if there are no query parameters
|
||||
redirect_url = request.full_path.replace("/logged_out", "", 1)
|
||||
if redirect_url.endswith("?"):
|
||||
redirect_url = redirect_url[:-1]
|
||||
|
||||
# Handle cases like /logged_out?asdf by adding a slash to the beginning
|
||||
if not redirect_url.startswith('/'):
|
||||
redirect_url = f"/{redirect_url}"
|
||||
|
||||
# Prevent redirect loop caused by visiting /logged_out/logged_out/logged_out/etc...
|
||||
if redirect_url.startswith('/logged_out'):
|
||||
abort(400)
|
||||
|
||||
return redirect(redirect_url)
|
||||
|
||||
@app.get("/privacy")
|
||||
@auth_required
|
||||
def privacy(v):
|
||||
|
@ -438,4 +456,4 @@ def googleplayapp():
|
|||
@app.post("/dismiss_mobile_tip")
|
||||
def dismiss_mobile_tip():
|
||||
session["tooltip_last_dismissed"] = int(time.time())
|
||||
return "", 204
|
||||
return "", 204
|
||||
|
|
Loading…
Reference in New Issue