From 4095a8804c17c3ec12706f00d3694f564afc0b95 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 4 Oct 2023 12:48:16 +0200 Subject: basic management of user permissions --- base/src/permission.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'base/src') diff --git a/base/src/permission.rs b/base/src/permission.rs index 8993154..382a16e 100644 --- a/base/src/permission.rs +++ b/base/src/permission.rs @@ -3,19 +3,19 @@ use anyhow::anyhow; use jellycommon::user::{PermissionSet, UserPermission}; pub trait PermissionSetExt { - fn check(&self, perm: UserPermission) -> bool; - fn assert(&self, perm: UserPermission) -> Result<(), anyhow::Error>; + fn check(&self, perm: &UserPermission) -> bool; + fn assert(&self, perm: &UserPermission) -> Result<(), anyhow::Error>; } impl PermissionSetExt for PermissionSet { - fn check(&self, perm: UserPermission) -> bool { + fn check(&self, perm: &UserPermission) -> bool { *self .0 .get(&perm) .or(CONF.default_permission_set.0.get(&perm)) .unwrap_or(&perm.default_value()) } - fn assert(&self, perm: UserPermission) -> Result<(), anyhow::Error> { + fn assert(&self, perm: &UserPermission) -> Result<(), anyhow::Error> { if self.check(perm) { Ok(()) } else { -- cgit v1.2.3-70-g09d2