mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user