From 9169cec4bb8b0c6fbc39f05b7bdf6807a93721c1 Mon Sep 17 00:00:00 2001 From: mStar Date: Thu, 7 Nov 2024 10:42:41 +0100 Subject: [PATCH] Fix: Better error handling Session insertion middleware now has better error handling for fetching an account based on a session. Not found is treated as not an error since it is likely to happen that a session is used post account deletion --- server/middlewares.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/middlewares.go b/server/middlewares.go index 5e594b7..5d088f7 100644 --- a/server/middlewares.go +++ b/server/middlewares.go @@ -132,7 +132,13 @@ func checkSessionMiddleware(handler http.Handler) http.Handler { return } acc, err := store.FindAccountByPasskeyId(session.UserID) - if err != nil { + switch err { + case storage.ErrEntryNotFound: + log.Info().Msg("No account for the given passkey id found. It probably got deleted") + handler.ServeHTTP(w, r) + return + case nil: + default: // Failed to get account for passkey id. Log, then move on as if no session is set log.Error(). Err(err).