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
This commit is contained in:
Melody Becker 2024-11-07 10:42:41 +01:00
parent ad68e97eaf
commit 9169cec4bb

View file

@ -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).