Inverted userRoles by role fix. Roles can now be updated
This commit is contained in:
@@ -26,6 +26,7 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
fmt.Println(token.IsSuperAdmin(gc))
|
||||
|
||||
if !token.IsSuperAdmin(gc) {
|
||||
return res, fmt.Errorf("unauthorized")
|
||||
@@ -133,6 +134,8 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
|
||||
inputRoles = append(inputRoles, *item)
|
||||
}
|
||||
|
||||
fmt.Println(envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyRoles))
|
||||
fmt.Println(envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyProtectedRoles))
|
||||
if !utils.IsValidRoles(inputRoles, append([]string{}, append(envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyRoles), envstore.EnvStoreObj.GetSliceStoreEnvVariable(constants.EnvKeyProtectedRoles)...)...)) {
|
||||
return res, fmt.Errorf("invalid list of roles")
|
||||
}
|
||||
|
@@ -54,8 +54,8 @@ func IsValidOrigin(url string) bool {
|
||||
// IsValidRoles validates roles
|
||||
func IsValidRoles(userRoles []string, roles []string) bool {
|
||||
valid := true
|
||||
for _, role := range roles {
|
||||
if !StringSliceContains(userRoles, role) {
|
||||
for _, userRole := range userRoles {
|
||||
if !StringSliceContains(roles, userRole) {
|
||||
valid = false
|
||||
break
|
||||
}
|
||||
|
Reference in New Issue
Block a user