domain update
This commit is contained in:
parent
e0253f04e7
commit
7360d429ff
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user