From dcc9a54fc8a1c52bb8cded28c4f445248bc597a6 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Thu, 12 Dec 2024 14:14:45 +0100 Subject: fix: Ignore error log for ErrNoCookie When an unlogged user request the page it will always return ErrNoCookie. --- pkg/ext/auth.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg/ext') diff --git a/pkg/ext/auth.go b/pkg/ext/auth.go index b57e86a..304f4ad 100644 --- a/pkg/ext/auth.go +++ b/pkg/ext/auth.go @@ -3,6 +3,7 @@ package ext import ( "context" "encoding/base64" + "errors" "log/slog" "net/http" ) @@ -24,7 +25,9 @@ func Authenticate(auth authService) func(next http.HandlerFunc) http.HandlerFunc return func(w http.ResponseWriter, r *http.Request) { cookie, err := r.Cookie("auth") if err != nil { - slog.Error("Error loading cookie", "error", err) + if !errors.Is(err, http.ErrNoCookie) { + slog.Error("Error loading cookie", "error", err) + } next(w, r) return } -- cgit v1.2.3