Include query parameters in login redirect.

This commit is contained in:
Patrick Fairbank
2020-04-04 14:19:47 -07:00
parent eb64939b20
commit b49afaa363
2 changed files with 17 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/Team254/cheesy-arena/model"
"github.com/google/uuid"
"net/http"
"net/url"
"time"
)
@@ -67,7 +68,11 @@ func (web *Web) userIsAdmin(w http.ResponseWriter, r *http.Request) bool {
if session != nil && session.Username == adminUser {
return true
} else {
http.Redirect(w, r, "/login?redirect="+r.URL.Path, 307)
redirect := r.URL.Path
if r.URL.RawQuery != "" {
redirect += "?" + r.URL.RawQuery
}
http.Redirect(w, r, "/login?redirect="+url.QueryEscape(redirect), 307)
return false
}
}