feat: add AccountExists method

This commit is contained in:
Derrick Hammer 2024-01-17 08:35:42 -05:00
parent ae0bddf3d1
commit 4ae272205a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 9 additions and 0 deletions

View File

@ -32,6 +32,14 @@ func (s AccountServiceImpl) PubkeyExists(pubkey string) (bool, models.PublicKey)
return result.RowsAffected > 0, model 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) { func (s AccountServiceImpl) CreateAccount(email string, password string) (*models.User, error) {
var user models.User var user models.User

View File

@ -5,6 +5,7 @@ import "git.lumeweb.com/LumeWeb/portal/db/models"
type AccountService interface { type AccountService interface {
EmailExists(email string) (bool, models.User) EmailExists(email string) (bool, models.User)
PubkeyExists(pubkey string) (bool, models.PublicKey) PubkeyExists(pubkey string) (bool, models.PublicKey)
AccountExists(id uint64) (bool, models.User)
CreateAccount(email string, password string) (*models.User, error) CreateAccount(email string, password string) (*models.User, error)
AddPubkeyToAccount(user models.User, pubkey string) error AddPubkeyToAccount(user models.User, pubkey string) error
LoginPassword(email string, password string) (string, error) LoginPassword(email string, password string) (string, error)