fix: l10n make path, validation context key type and available role env

This commit is contained in:
Florian Schade
2024-08-23 14:24:19 +02:00
parent 43ba95190f
commit 803a0a5c38
5 changed files with 10 additions and 8 deletions
+6 -4
View File
@@ -10,8 +10,10 @@ import (
"github.com/owncloud/ocis/v2/services/graph/pkg/unifiedrole"
)
var (
_contextRoleIDsValueKey = "roleFilterIDs"
type contextKey int
const (
ContextKeyRoleIDsValueKey contextKey = iota
)
// initLibregraph initializes libregraph validation
@@ -88,7 +90,7 @@ func rolesAndActions(ctx context.Context, sl validator.StructLevel, roles, actio
var availableActions []string
var definitions []*libregraph.UnifiedRoleDefinition
switch roles, ok := ctx.Value(_contextRoleIDsValueKey).([]string); {
switch roles, ok := ctx.Value(ContextKeyRoleIDsValueKey).([]string); {
case ok:
definitions = unifiedrole.GetRoles(unifiedrole.RoleFilterIDs(roles...))
default:
@@ -133,5 +135,5 @@ func rolesAndActions(ctx context.Context, sl validator.StructLevel, roles, actio
// ContextWithAllowedRoleIDs returns a new context which includes the allowed role IDs.
func ContextWithAllowedRoleIDs(ctx context.Context, rolesIds []string) context.Context {
return context.WithValue(ctx, _contextRoleIDsValueKey, rolesIds)
return context.WithValue(ctx, ContextKeyRoleIDsValueKey, rolesIds)
}