From 3ab05490b4fb317f60ba1692e5b8a6305a27d5a5 Mon Sep 17 00:00:00 2001 From: Umputun Date: Fri, 7 Sep 2018 14:48:58 -0500 Subject: [PATCH] lint: warn on basic auth and non-handled err in gridfs avatar --- backend/app/rest/auth/auth.go | 4 ++-- backend/app/store/avatar/gridfs.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/app/rest/auth/auth.go b/backend/app/rest/auth/auth.go index ef642948..7af61c9e 100644 --- a/backend/app/rest/auth/auth.go +++ b/backend/app/rest/auth/auth.go @@ -58,7 +58,7 @@ func (a *Authenticator) Auth(reqAuth bool) func(http.Handler) http.Handler { } // use dev user basic auth if enabled - if a.basicDevUser(w, r) { + if a.basicDevUser(r) { r = rest.SetUserInfo(r, devUser) h.ServeHTTP(w, r) return @@ -166,7 +166,7 @@ func (a *Authenticator) AdminOnly(next http.Handler) http.Handler { return http.HandlerFunc(fn) } -func (a *Authenticator) basicDevUser(w http.ResponseWriter, r *http.Request) bool { +func (a *Authenticator) basicDevUser(r *http.Request) bool { if a.DevPasswd == "" { return false diff --git a/backend/app/store/avatar/gridfs.go b/backend/app/store/avatar/gridfs.go index f6103f1c..0110b2e1 100644 --- a/backend/app/store/avatar/gridfs.go +++ b/backend/app/store/avatar/gridfs.go @@ -89,7 +89,9 @@ func (gf *GridFS) Remove(avatar string) error { if e != nil { return errors.Wrapf(e, "can't get avatar %s", avatar) } - _ = fh.Close() + if e = fh.Close(); e != nil { + log.Printf("[WARN] can't close avatar %s, %s", avatar, e) + } return dbase.GridFS("fs").Remove(avatar) }) }