1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-03 16:40:18 +00:00

beego: XSRF support Controller level fix #610

default value is true when you Enable Global XSRF, also can control in
the prepare function to change the value.
This commit is contained in:
astaxie
2014-05-17 00:12:25 +08:00
parent e657dcfd5f
commit c5c806b58e
3 changed files with 14 additions and 4 deletions

View File

@ -906,6 +906,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
//call the controller init function
execController.Init(context, runrouter.Name(), runMethod, vc.Interface())
//call prepare function
execController.Prepare()
//if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf
if EnableXSRF {
execController.XsrfToken()
@ -915,9 +918,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
}
}
//call prepare function
execController.Prepare()
if !w.started {
//exec main logic
switch runMethod {