sofie_identity/role_grant/
mod.rs1pub(crate) mod factory;
2
3use sofie::prelude::*;
4
5use crate::role::RoleId;
6
7#[derive(Aggregate)]
9#[aggregate(behaviors(SoftDelete))]
10pub struct RoleGrant {
11 meta: Meta,
12 role: RoleId,
13 permission: String,
14}
15
16pub(crate) async fn granted(read: &Read, role: RoleId) -> Result<Vec<String>> {
17 let grants = RoleGrant::query()
18 .where_(RoleGrant::ROLE.eq(role))
19 .all(read)
20 .await?;
21 Ok(grants.into_iter().map(|grant| grant.permission).collect())
22}