Adjust shift plan based on authentication

This commit is contained in:
Simon Goller 2024-06-14 13:23:12 +02:00
parent f894bf325d
commit b4b926a8e4
10 changed files with 499 additions and 97 deletions

View file

@ -6,6 +6,10 @@ use mockall::automock;
use crate::ServiceError;
pub const SALES_PRIVILEGE: &str = "sales";
pub const HR_PRIVILEGE: &str = "hr";
pub const SHIFTPLANNER_PRIVILEGE: &str = "shiftplanner";
/// For mocking the context locally since there is actually
/// no context.
#[derive(Clone, Debug, PartialEq, Eq)]
@ -74,6 +78,11 @@ pub trait PermissionService {
privilege: &str,
context: Authentication<Self::Context>,
) -> Result<(), ServiceError>;
async fn check_user(
&self,
user: &str,
context: Authentication<Self::Context>,
) -> Result<(), ServiceError>;
async fn get_privileges_for_current_user(
&self,
context: Authentication<Self::Context>,