cal_core/authentication/
permissions.rs

1// File: cal-core/src/authentication/permissions.rs
2
3/// Check if a user has a specific permission
4pub fn has_permission(groups: &[String], permission: &str) -> bool {
5    groups.iter().any(|g| g == permission)
6}
7
8/// Check if a user is an admin
9pub fn is_admin(groups: &[String]) -> bool {
10    groups.contains(&"Admin".to_string())
11}
12
13/// Check if softphone is enabled based on agent settings
14pub fn is_softphone_enabled(agent_settings: &Option<crate::AgentSettings>) -> bool {
15    match agent_settings {
16        Some(settings) => {
17            settings.client.is_some() && settings.ddi.is_some()
18        }
19        None => false,
20    }
21}