added a interface for userService

This commit is contained in:
James Tombleson 2024-04-21 08:57:32 -07:00
parent f5eea08c1e
commit 8d8781eac4

View File

@ -17,6 +17,16 @@ const (
ErrInvalidPassword = "invalid password" ErrInvalidPassword = "invalid password"
) )
type Users interface {
DoesUserExist(username string) error
DoesPasswordMatchHash(username, password string) error
GetUser(username string) (domain.UserEntity, error)
AddScopes(username string, scopes []string) error
RemoveScopes(username string, scopes []string) error
Create(name, password, scope string) (domain.UserEntity, error)
CheckPasswordForRequirements(password string) error
}
// This will handle operations that are user related, but one layer higher then the repository // This will handle operations that are user related, but one layer higher then the repository
type UserService struct { type UserService struct {
repo repositories.IUserTable repo repositories.IUserTable
@ -111,7 +121,7 @@ func (us UserService) doesScopeExist(scopes []string, target string) bool {
return false return false
} }
func (us UserService) CreateNewUser(name, password, scope string) (domain.UserEntity, error) { func (us UserService) Create(name, password, scope string) (domain.UserEntity, error) {
err := us.CheckPasswordForRequirements(password) err := us.CheckPasswordForRequirements(password)
if err != nil { if err != nil {
return domain.UserEntity{}, err return domain.UserEntity{}, err