added a interface for userService
This commit is contained in:
parent
f5eea08c1e
commit
8d8781eac4
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user