From 69fb7a683b20e2641745fe49edd461f37902e4d4 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Thu, 4 Apr 2024 15:30:59 -0700 Subject: [PATCH] updated how it looks to see what scopes to add --- api/services/userService.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/services/userService.go b/api/services/userService.go index 816cbff..5c21787 100644 --- a/api/services/userService.go +++ b/api/services/userService.go @@ -63,15 +63,15 @@ func (us UserService) AddScopes(username string, scopes []string) error { return errors.New(repositories.ErrUserNotFound) } - newScopes := strings.Split(usr.Scopes, ",") + currentScopes := strings.Split(usr.Scopes, ",") // check the current scopes - for _, item := range strings.Split(usr.Scopes, ",") { - if !us.doesScopeExist(scopes, item) { - newScopes = append(newScopes, item) + for _, item := range scopes { + if !strings.Contains(usr.Scopes, item) { + currentScopes = append(currentScopes, item) } } - return us.repo.UpdateScopes(username, strings.Join(newScopes, ",")) + return us.repo.UpdateScopes(username, strings.Join(currentScopes, ",")) } func (us UserService) RemoveScopes(username string, scopes []string) error {