Fix panic on CSRF middleware failure
This commit is contained in:
parent
d66ba92f55
commit
6dcb0c66e8
|
@ -86,9 +86,9 @@ func New() http.Handler {
|
||||||
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(config.StaticPath))))
|
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(config.StaticPath))))
|
||||||
|
|
||||||
// Global middlewares.
|
// Global middlewares.
|
||||||
withSession := middleware.Session(mux)
|
withCSRF := middleware.CSRF(mux)
|
||||||
withCSRF := middleware.CSRF(withSession)
|
withSession := middleware.Session(withCSRF)
|
||||||
withRecovery := middleware.Recovery(withCSRF)
|
withRecovery := middleware.Recovery(withSession)
|
||||||
withLogger := middleware.Logging(withRecovery)
|
withLogger := middleware.Logging(withRecovery)
|
||||||
return withLogger
|
return withLogger
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,6 +195,10 @@ func ImpersonateUser(w http.ResponseWriter, r *http.Request, u *models.User, imp
|
||||||
// Impersonated returns if the current session has an impersonator.
|
// Impersonated returns if the current session has an impersonator.
|
||||||
func Impersonated(r *http.Request) bool {
|
func Impersonated(r *http.Request) bool {
|
||||||
sess := Get(r)
|
sess := Get(r)
|
||||||
|
if sess == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return sess.Impersonator > 0
|
return sess.Impersonator > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user