From cefa80f31703c9d7cff450bb78d778c0482496cb Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Tue, 22 Mar 2022 16:17:12 -0400 Subject: [PATCH] Fixed redirect functionality --- src/dashboard.py | 5 ++++- src/templates/signin.html | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index 2aecb02..16dfbd1 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -653,7 +653,10 @@ def auth_req(): else: session['message'] = "" conf.clear() - return redirect("/signin?redirect=" + str(request.url)) + redirectURL = str(request.url) + redirectURL = redirectURL.replace("http://", "") + redirectURL = redirectURL.replace("https://", "") + return redirect("/signin?redirect=" + redirectURL) else: if request.endpoint in ['signin', 'signout', 'auth', 'settings', 'update_acct', 'update_pwd', 'update_app_ip_port', 'update_wg_conf_path']: diff --git a/src/templates/signin.html b/src/templates/signin.html index 16e5e1b..0a49285 100644 --- a/src/templates/signin.html +++ b/src/templates/signin.html @@ -67,7 +67,11 @@ if (res.status === true){ const urlParams = new URLSearchParams(window.location.search); if (urlParams.get("redirect")){ - window.location.replace(urlParams.get("redirect")) + if (document.URL.substring(0, 5) == "http:"){ + window.location.replace(`http://${urlParams.get("redirect")}`) + }else if (document.URL.substring(0, 5) == "https"){ + window.location.replace(`https://${urlParams.get("redirect")}`) + } }else{ window.location.replace("/"); }