mirror of
https://github.com/go-gitea/gitea
synced 2025-07-13 22:17:20 +00:00
Convert captcha, cache, csrf as middlewares
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/Unknwon/macaron"
|
||||
"github.com/macaron-contrib/csrf"
|
||||
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
@ -34,9 +35,11 @@ func Toggle(options *ToggleOptions) macaron.Handler {
|
||||
return
|
||||
}
|
||||
|
||||
if !options.DisableCsrf && ctx.Req.Method == "POST" && !ctx.CsrfTokenValid() {
|
||||
ctx.Error(403, "CSRF token does not match")
|
||||
return
|
||||
if !options.SignOutRequire && !options.DisableCsrf && ctx.Req.Method == "POST" {
|
||||
csrf.Validate(ctx.Context, ctx.csrf)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if options.SignInRequire {
|
||||
|
Reference in New Issue
Block a user