feat: add user roles and storage quota management

This commit is contained in:
2025-11-02 17:17:13 +01:00
parent 596313b8c5
commit f49d9179f5
10 changed files with 183 additions and 30 deletions

View File

@@ -0,0 +1,25 @@
use uuid::Uuid;
use crate::models::{Album, Media, Role, User};
pub trait Ownable {
fn owner_id(&self) -> Uuid;
}
impl Ownable for Media {
fn owner_id(&self) -> Uuid {
self.owner_id
}
}
impl Ownable for Album {
fn owner_id(&self) -> Uuid {
self.owner_id
}
}
pub fn is_admin(user: &User) -> bool {
user.role == Role::Admin
}
pub fn is_owner(user_id: Uuid, entity: &impl Ownable) -> bool {
user_id == entity.owner_id()
}