Skip to content

Commit 9edc8d0

Browse files
committed
Inverted userRoles by role fix. Roles can now be updated
1 parent 773213e commit 9edc8d0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

server/resolvers/update_user.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
2626
if err != nil {
2727
return res, err
2828
}
29+
fmt.Println(token.IsSuperAdmin(gc))
2930

3031
if !token.IsSuperAdmin(gc) {
3132
return res, fmt.Errorf("unauthorized")
@@ -133,6 +134,8 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
133134
inputRoles = append(inputRoles, *item)
134135
}
135136

137+
fmt.Println(envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyRoles))
138+
fmt.Println(envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyProtectedRoles))
136139
if !utils.IsValidRoles(inputRoles, append([]string{}, append(envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyRoles), envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyProtectedRoles)...)...)) {
137140
return res, fmt.Errorf("invalid list of roles")
138141
}

server/utils/validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func IsValidOrigin(url string) bool {
5454
// IsValidRoles validates roles
5555
func IsValidRoles(userRoles []string, roles []string) bool {
5656
valid := true
57-
for _, role := range roles {
58-
if !StringSliceContains(userRoles, role) {
57+
for _, userRole := range userRoles {
58+
if !StringSliceContains(roles, userRole) {
5959
valid = false
6060
break
6161
}

0 commit comments

Comments
 (0)