fabaccess-bffh/bffhd/authorization/mod.rs
Nadja Reitzenstein c0b311e14c Cargo fix
2022-03-15 20:00:43 +01:00

25 lines
491 B
Rust

use crate::authorization::roles::{Roles};
use crate::Users;
pub mod permissions;
pub mod roles;
#[derive(Clone)]
pub struct AuthorizationHandle {
users: Users,
roles: Roles,
}
impl AuthorizationHandle {
pub fn new(users: Users, roles: Roles) -> Self {
Self { users, roles }
}
pub fn get_user_roles(&self, uid: impl AsRef<str>) -> Option<Vec<String>> {
let user = self.users.get_user(uid.as_ref())?;
Some(user.userdata.roles.clone())
}
}