From 7c96e1b780243bfbe3ecc5b6874fe3497e2419d5 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 15 Nov 2024 23:59:14 +0100 Subject: fix(tfstated): return 403 Forbidden on non existent account --- pkg/database/accounts.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkg/database') diff --git a/pkg/database/accounts.go b/pkg/database/accounts.go index 7902371..3919709 100644 --- a/pkg/database/accounts.go +++ b/pkg/database/accounts.go @@ -2,6 +2,7 @@ package database import ( "database/sql" + "errors" "fmt" "log/slog" "time" @@ -32,6 +33,9 @@ func (db *DB) LoadAccountByUsername(username string) (*model.Account, error) { &account.Settings, ) if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } return nil, err } password, err := db.dataEncryptionKey.DecryptAES256(encryptedPassword) -- cgit v1.2.3