+ checkin mod::auth for valid permissions
+ helper function for getting a permission mask from permissions module
This commit is contained in:
@@ -8,6 +8,7 @@ pub const CREATE_TMP_INVITES:u64 = 4;
|
||||
pub const CREATE_PERM_INVITES:u64 = 8; // to make perma invites you need both flags
|
||||
|
||||
|
||||
|
||||
pub const OWNER: u64 = 1 << 63;
|
||||
pub const ADMIN: u64 = 1 << 62; // can make other admins but can't really touch the owner
|
||||
|
||||
@@ -19,3 +20,21 @@ pub const DELETE_CHANNEL:u64 = 128;
|
||||
pub const OWNER_PERMS: u64 = std::u64::MAX;
|
||||
pub const GENERAL_NEW: u64 = JOIN_VOICE | SEND_MESSAGES | ALLOW_PFP | CHANGE_NICK;
|
||||
pub const ADMIN_PERMS: u64 = !(std::u64::MAX & OWNER); // filter the only perm admins don't get
|
||||
|
||||
pub fn get_perm_mask(path: &str) -> Option<u64> {
|
||||
use crate::routes::{
|
||||
INVITE_CREATE,
|
||||
CHANNELS_LIST, CHANNELS_CREATE, CHANNELS_DELETE,
|
||||
MESSAGE_SEND,
|
||||
SERVER_META,
|
||||
};
|
||||
match path {
|
||||
INVITE_CREATE => Some(CREATE_TMP_INVITES),
|
||||
CHANNELS_LIST => None,
|
||||
CHANNELS_CREATE => Some(CREATE_CHANNEL),
|
||||
CHANNELS_DELETE => Some(DELETE_CHANNEL),
|
||||
MESSAGE_SEND => Some(SEND_MESSAGES),
|
||||
SERVER_META => None,
|
||||
_ => Some(0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user