From 4ae272205abce153ce853347899fc921d4ce3b9b Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 17 Jan 2024 08:35:42 -0500 Subject: [PATCH] feat: add AccountExists method --- account/account.go | 8 ++++++++ interfaces/account.go | 1 + 2 files changed, 9 insertions(+) diff --git a/account/account.go b/account/account.go index 3577ead..23eb741 100644 --- a/account/account.go +++ b/account/account.go @@ -32,6 +32,14 @@ func (s AccountServiceImpl) PubkeyExists(pubkey string) (bool, models.PublicKey) return result.RowsAffected > 0, model } + +func (s AccountServiceImpl) AccountExists(id uint64) (bool, models.User) { + var model models.User + + result := s.portal.Database().Model(&models.User{}).First(&model, id) + + return result.RowsAffected > 0, model +} func (s AccountServiceImpl) CreateAccount(email string, password string) (*models.User, error) { var user models.User diff --git a/interfaces/account.go b/interfaces/account.go index 696d47d..94e9901 100644 --- a/interfaces/account.go +++ b/interfaces/account.go @@ -5,6 +5,7 @@ import "git.lumeweb.com/LumeWeb/portal/db/models" type AccountService interface { EmailExists(email string) (bool, models.User) PubkeyExists(pubkey string) (bool, models.PublicKey) + AccountExists(id uint64) (bool, models.User) CreateAccount(email string, password string) (*models.User, error) AddPubkeyToAccount(user models.User, pubkey string) error LoginPassword(email string, password string) (string, error)