ilk
This commit is contained in:
33
svc/permissions/role_policy.go
Normal file
33
svc/permissions/role_policy.go
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user