Files
bssapp/svc/permissions/role_policy.go
2026-02-11 17:46:22 +03:00

34 lines
676 B
Go

package permissions
// 🔥 SYSTEM / ADMIN ROLE IDS
var AdminRoleIDs = map[int]struct{}{
1: {},
3: {},
}
// -------------------------------------------------------
// 🧠 ROLE POLICY
// -------------------------------------------------------
func ResolveEffectiveRoles(
roleIDs []int,
) (effectiveRoleIDs []int, isAdmin bool) {
roleMap := make(map[int]struct{})
for _, roleID := range roleIDs {
// 🔥 SYSTEM / ADMIN OVERRIDE (1,3,…)
if _, ok := AdminRoleIDs[roleID]; ok {
return []int{roleID}, true
}
roleMap[roleID] = struct{}{}
}
for id := range roleMap {
effectiveRoleIDs = append(effectiveRoleIDs, id)
}
return effectiveRoleIDs, false
}