features/working-on-scopes #13

Merged
jtom38 merged 28 commits from features/working-on-scopes into main 2024-04-04 15:31:54 -07:00
Showing only changes of commit 7360d429ff - Show all commits

View File

@ -3,7 +3,7 @@ package services
import ( import (
"database/sql" "database/sql"
"errors" "errors"
"go-cook/api/models" "go-cook/api/domain"
"go-cook/api/repositories" "go-cook/api/repositories"
"strings" "strings"
@ -36,12 +36,6 @@ func (us UserService) DoesUserExist(username string) error {
} }
func (us UserService) DoesPasswordMatchHash(username, password string) error { func (us UserService) DoesPasswordMatchHash(username, password string) error {
//passwordBytes := []byte(password)
//hash, err := bcrypt.GenerateFromPassword(passwordBytes, bcrypt.DefaultCost)
//if err != nil {
// return err
//}
model, err := us.GetUser(username) model, err := us.GetUser(username)
if err != nil { if err != nil {
return err return err
@ -55,18 +49,18 @@ func (us UserService) DoesPasswordMatchHash(username, password string) error {
return nil return nil
} }
func (us UserService) GetUser(username string) (models.UserModel, error) { func (us UserService) GetUser(username string) (domain.UserEntity, error) {
return us.repo.GetByName(username) return us.repo.GetByName(username)
} }
func (us UserService) CreateNewUser(name, password string) (models.UserModel, error) { func (us UserService) CreateNewUser(name, password string) (domain.UserEntity, error) {
err := us.CheckPasswordForRequirements(password) err := us.CheckPasswordForRequirements(password)
if err != nil { if err != nil {
return models.UserModel{}, err return domain.UserEntity{}, err
} }
us.repo.Create(name, password) us.repo.Create(name, password)
return models.UserModel{}, nil return domain.UserEntity{}, nil
} }
func (us UserService) CheckPasswordForRequirements(password string) error { func (us UserService) CheckPasswordForRequirements(password string) error {