diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-07-31 17:25:34 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-07-31 17:25:34 -0400 |
commit | 7bbf644dd5eaca77c3e8df57419180486bda0fc2 (patch) | |
tree | 84033fb9507c4657d74b85dccd5f16595f8517a8 /modules/middleware/auth.go | |
parent | 3428baa3b57b39f2e010254bffede93e7d3cdf37 (diff) | |
download | gitea-7bbf644dd5eaca77c3e8df57419180486bda0fc2.tar.gz gitea-7bbf644dd5eaca77c3e8df57419180486bda0fc2.zip |
Convert captcha, cache, csrf as middlewares
Diffstat (limited to 'modules/middleware/auth.go')
-rw-r--r-- | modules/middleware/auth.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 741337da0b..29a2d68110 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -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 { |