diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-01 00:38:29 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-01 00:38:29 +0200 |
commit | fc5e13ae525cb74e77a5bc51204f44476115cea9 (patch) | |
tree | a20b6d296d67735a2c8d42a0dc31b44c0bb53cb7 /common/src/user.rs | |
parent | d546caa3f5053ade763430490911fefd6257af9f (diff) | |
download | jellything-fc5e13ae525cb74e77a5bc51204f44476115cea9.tar jellything-fc5e13ae525cb74e77a5bc51204f44476115cea9.tar.bz2 jellything-fc5e13ae525cb74e77a5bc51204f44476115cea9.tar.zst |
draft for permission framework
Diffstat (limited to 'common/src/user.rs')
-rw-r--r-- | common/src/user.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/common/src/user.rs b/common/src/user.rs new file mode 100644 index 0000000..543162c --- /dev/null +++ b/common/src/user.rs @@ -0,0 +1,30 @@ +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct User { + pub name: String, + pub display_name: String, + pub password: Vec<u8>, + pub admin: bool, + pub permissions: PermissionSet, +} + +#[derive(Debug, Clone, Serialize, Deserialize, Default)] +pub struct PermissionSet(pub HashMap<UserPermission, bool>); + +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[serde(rename_all = "snake_case")] +pub enum UserPermission { + OriginalStream, + Transcode, + ManageUsers, + GenerateInvite, +} + +impl UserPermission { + pub fn default_value(&self) -> bool { + use UserPermission::*; + matches!(self, Transcode) + } +} |