Make the migration cookie work properly on older servers
This commit is contained in:
parent
52324e269c
commit
44c91c39dc
12
main
12
main
|
@ -664,7 +664,7 @@ async def login():
|
||||||
|
|
||||||
response = Response("""<script>window.location.href = "/oauth";</script>""")
|
response = Response("""<script>window.location.href = "/oauth";</script>""")
|
||||||
response.set_cookie("session_DO_NOT_SHARE", randomCharacters, samesite="Strict", secure=True)
|
response.set_cookie("session_DO_NOT_SHARE", randomCharacters, samesite="Strict", secure=True)
|
||||||
response.set_cookie("legacy_migrate", "1", samesite="Strict", secure=True)
|
session["legacy_migrate"] = True
|
||||||
return response
|
return response
|
||||||
|
|
||||||
#resp = await make_response(redirect("/"))
|
#resp = await make_response(redirect("/"))
|
||||||
|
@ -677,8 +677,12 @@ async def login():
|
||||||
|
|
||||||
@app.route("/oauth", methods=("GET", "POST"))
|
@app.route("/oauth", methods=("GET", "POST"))
|
||||||
async def oauth():
|
async def oauth():
|
||||||
legacymigrate = request.cookies.get("legacy_migrate")
|
try:
|
||||||
if legacymigrate != "1":
|
legacymigrate = session["legacy_migrate"]
|
||||||
|
except:
|
||||||
|
session["legacy_migrate"] = False
|
||||||
|
legacymigrate = False
|
||||||
|
if not legacymigrate:
|
||||||
return await render_template("oauth.html")
|
return await render_template("oauth.html")
|
||||||
else:
|
else:
|
||||||
return await render_template("migrate.html")
|
return await render_template("migrate.html")
|
||||||
|
@ -753,7 +757,7 @@ async def logout():
|
||||||
session = request.cookies.get("session_DO_NOT_SHARE")
|
session = request.cookies.get("session_DO_NOT_SHARE")
|
||||||
resp.delete_cookie("session_DO_NOT_SHARE")
|
resp.delete_cookie("session_DO_NOT_SHARE")
|
||||||
resp.delete_cookie("prefuser")
|
resp.delete_cookie("prefuser")
|
||||||
resp.delete_cookie("legacy_migrate")
|
resp.delete_cookie("session")
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@app.errorhandler(500)
|
@app.errorhandler(500)
|
||||||
|
|
|
@ -121,7 +121,6 @@
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
async function doStuff2() {
|
async function doStuff2() {
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
document.cookie = "legacy_migrate=; Max-Age=0; path=/;"
|
|
||||||
window.location.replace("/")
|
window.location.replace("/")
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("text").innerText = "Failed: " + key["error"]
|
document.getElementById("text").innerText = "Failed: " + key["error"]
|
||||||
|
|
Reference in New Issue