fix: redirect unauthorized git users to login screen (#10995)

* fix: redirect to login screen if unauthorized git user

* consolidated language

* fix redirect
This commit is contained in:
Kira Pilot
2023-12-07 09:19:31 -05:00
committed by GitHub
parent 5d2e87f1a7
commit 091fdd6761
5 changed files with 26 additions and 15 deletions
+15
View File
@@ -538,3 +538,18 @@ func RedirectToLogin(rw http.ResponseWriter, r *http.Request, dashboardURL *url.
// (like temporary redirect does).
http.Redirect(rw, r, u.String(), http.StatusSeeOther)
}
// CustomRedirectToLogin redirects the user to the login page with the `message` and
// `redirect` query parameters set, with a provided code
func CustomRedirectToLogin(rw http.ResponseWriter, r *http.Request, redirect string, message string, code int) {
q := url.Values{}
q.Add("message", message)
q.Add("redirect", redirect)
u := &url.URL{
Path: "/login",
RawQuery: q.Encode(),
}
http.Redirect(rw, r, u.String(), code)
}