Commit 7a278991 authored by Nicolas Pernoud's avatar Nicolas Pernoud
Browse files

fix: do not redirect on favicon and keep query in redirect after login

parent 08cd35cc
Pipeline #14632 passed with stages
in 2 minutes and 39 seconds
......@@ -80,8 +80,8 @@ func ValidateAuthMiddleware(next http.Handler, allowedRoles []string, checkXSRF
redirectTo += ":" + port
}
// Write the requested url in a cookie
if r.Host != redirectTo {
cookie := http.Cookie{Name: "redirectAfterLogin", Domain: hostname, Value: r.Host + r.URL.Path, MaxAge: 30, Secure: true, HttpOnly: false, SameSite: http.SameSiteLaxMode}
if r.Host != redirectTo && r.URL.Path != "/favicon.ico" {
cookie := http.Cookie{Name: "redirectAfterLogin", Domain: hostname, Value: r.Host + r.URL.Path + "?" + r.URL.RawQuery, MaxAge: 30, Secure: true, HttpOnly: false, SameSite: http.SameSiteLaxMode}
http.SetCookie(w, &cookie)
}
w.Header().Set("Content-Type", "text/html")
......
......@@ -20,7 +20,7 @@ export async function GetUser() {
const redirectAfterLogin = document.cookie
.split("; ")
.find((row) => row.startsWith("redirectAfterLogin="))
.split("=")[1];
.split(/=(.+)/)[1];
if (redirectAfterLogin != "" && redirectAfterLogin != null) {
window.location.replace("https://" + redirectAfterLogin);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment