From 487b57b4d62ee440bb929d1b005d85fb254d92d8 Mon Sep 17 00:00:00 2001 From: mStar Date: Thu, 7 Nov 2024 10:45:57 +0100 Subject: [PATCH] Fix (account): return error, implement deletion Fixed returning the wrong error if an account isn't found in a passkey id request Implemented account deletion --- storage/user.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/user.go b/storage/user.go index 440d5f6..0da6efc 100644 --- a/storage/user.go +++ b/storage/user.go @@ -267,10 +267,11 @@ func (s *Storage) FindAccountByPasskeyId(pkeyId []byte) (*Account, error) { log.Info(). Bytes("account-passkey-id", pkeyId). Msg("Local account with passkey id not found") + return nil, ErrEntryNotFound } else { log.Error().Err(res.Error).Bytes("account-passkey-id", pkeyId).Msg("Failed to get local account with passkey id") + return nil, res.Error } - return nil, res.Error } log.Info().Bytes("account-passkey-id", pkeyId).Msg("Found account, also inserting into cache") // if err = s.cache.Set(cacheUserIdToAccPrefix+acc.ID, &acc); err != nil { @@ -392,8 +393,8 @@ func (s *Storage) NewLocalAccount(handle string) (*Account, error) { } func (s *Storage) DeleteAccount(accId string) error { - // TODO: Implement me - panic("Not implemented") + defer util.Untrace(util.Trace(&log.Logger)) + return s.db.Delete(&Account{ID: accId}).Error } // ---- Section WebAuthn.User