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))))
|
||||
|
||||
// Global middlewares.
|
||||
withSession := middleware.Session(mux)
|
||||
withCSRF := middleware.CSRF(withSession)
|
||||
withRecovery := middleware.Recovery(withCSRF)
|
||||
withCSRF := middleware.CSRF(mux)
|
||||
withSession := middleware.Session(withCSRF)
|
||||
withRecovery := middleware.Recovery(withSession)
|
||||
withLogger := middleware.Logging(withRecovery)
|
||||
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.
|
||||
func Impersonated(r *http.Request) bool {
|
||||
sess := Get(r)
|
||||
if sess == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return sess.Impersonator > 0
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user