Auth: Write the redirect cookie if denied - do not write a blank redirect (#57381)

* Write the redirect cookie if denied - do not write a blank redirect

* Remove redundant code, reverse polarity
This commit is contained in:
Kristina 2022-10-21 09:53:17 -05:00 committed by GitHub
parent 98053cfde8
commit 5d7d54d076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -64,9 +64,12 @@ func writeRedirectCookie(c *models.ReqContext) {
redirectTo = setting.AppSubUrl + c.Req.RequestURI
}
if redirectTo == "/" {
return
}
// remove any forceLogin=true params
redirectTo = removeForceLoginParams(redirectTo)
cookies.WriteCookie(c.Resp, "redirect_to", url.QueryEscape(redirectTo), 0, nil)
}

View File

@ -84,6 +84,7 @@ func deny(c *models.ReqContext, evaluator Evaluator, err error) {
if !c.IsApiRequest() {
// TODO(emil): I'd like to show a message after this redirect, not sure how that can be done?
writeRedirectCookie(c)
c.Redirect(setting.AppSubUrl + "/")
return
}