From 8d8781eac4720ca92a32c0e7b1f92d35224aa4e8 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sun, 21 Apr 2024 08:57:32 -0700 Subject: [PATCH] added a interface for userService --- internal/services/userService.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/services/userService.go b/internal/services/userService.go index decb30f..ec626e5 100644 --- a/internal/services/userService.go +++ b/internal/services/userService.go @@ -17,6 +17,16 @@ const ( 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 type UserService struct { repo repositories.IUserTable @@ -111,7 +121,7 @@ func (us UserService) doesScopeExist(scopes []string, target string) bool { 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) if err != nil { return domain.UserEntity{}, err