Fix userlevel error logging

Previously, we just included the value of `ul`, which is a func. This
now calls `ul()` and logs that value.
pull/123/head
Matt Baer 5 years ago
parent 77bf403443
commit 60a6848361
  1. 6
      handle.go

@ -390,7 +390,7 @@ func (h *Handler) WebErrors(f handlerFunc, ul UserLevelFunc) http.HandlerFunc {
session, err = h.sessionStore.Get(r, cookieName) session, err = h.sessionStore.Get(r, cookieName)
if err != nil && (ul(h.app.App().cfg) == UserLevelNoneRequiredType || ul(h.app.App().cfg) == UserLevelUserType) { if err != nil && (ul(h.app.App().cfg) == UserLevelNoneRequiredType || ul(h.app.App().cfg) == UserLevelUserType) {
// Cookie is required, but we can ignore this error // Cookie is required, but we can ignore this error
log.Error("Handler: Unable to get session (for user permission %d); ignoring: %v", ul, err) log.Error("Handler: Unable to get session (for user permission %d); ignoring: %v", ul(h.app.App().cfg), err)
} }
_, gotUser := session.Values[cookieUserVal].(*User) _, gotUser := session.Values[cookieUserVal].(*User)
@ -479,7 +479,7 @@ func (h *Handler) Web(f handlerFunc, ul UserLevelFunc) http.HandlerFunc {
session, err := h.sessionStore.Get(r, cookieName) session, err := h.sessionStore.Get(r, cookieName)
if err != nil && (ul(h.app.App().cfg) == UserLevelNoneRequiredType || ul(h.app.App().cfg) == UserLevelUserType) { if err != nil && (ul(h.app.App().cfg) == UserLevelNoneRequiredType || ul(h.app.App().cfg) == UserLevelUserType) {
// Cookie is required, but we can ignore this error // Cookie is required, but we can ignore this error
log.Error("Handler: Unable to get session (for user permission %d); ignoring: %v", ul, err) log.Error("Handler: Unable to get session (for user permission %d); ignoring: %v", ul(h.app.App().cfg), err)
} }
_, gotUser := session.Values[cookieUserVal].(*User) _, gotUser := session.Values[cookieUserVal].(*User)
@ -662,7 +662,7 @@ func (h *Handler) Redirect(url string, ul UserLevelFunc) http.HandlerFunc {
session, err := h.sessionStore.Get(r, cookieName) session, err := h.sessionStore.Get(r, cookieName)
if err != nil && (ul(h.app.App().cfg) == UserLevelNoneRequiredType || ul(h.app.App().cfg) == UserLevelUserType) { if err != nil && (ul(h.app.App().cfg) == UserLevelNoneRequiredType || ul(h.app.App().cfg) == UserLevelUserType) {
// Cookie is required, but we can ignore this error // Cookie is required, but we can ignore this error
log.Error("Handler: Unable to get session (for user permission %d); ignoring: %v", ul, err) log.Error("Handler: Unable to get session (for user permission %d); ignoring: %v", ul(h.app.App().cfg), err)
} }
_, gotUser := session.Values[cookieUserVal].(*User) _, gotUser := session.Values[cookieUserVal].(*User)

Loading…
Cancel
Save