1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Determine access level of a user over a group

This commit is contained in:
2020-06-24 14:08:46 +02:00
parent 4d844ccbad
commit b89a319cfb
5 changed files with 102 additions and 2 deletions

View File

@ -11,7 +11,7 @@ pub enum GroupVisibilityLevel {
}
#[allow(non_camel_case_types)]
#[derive(Eq, PartialEq, Hash)]
#[derive(Eq, PartialEq, Hash, Debug)]
pub enum GroupAccessLevel {
//Can not even know if the group exists or not
NO_ACCESS = 0,

View File

@ -5,6 +5,7 @@
use crate::data::user::UserID;
use crate::data::group_id::GroupID;
#[derive(PartialEq, Eq)]
pub enum GroupMembershipLevel {
ADMINISTRATOR = 0,
MODERATOR = 1,

View File

@ -465,8 +465,10 @@ impl HttpRequestHandler {
/// Get the ID of a group included in a request with a check for access level of current user
pub fn post_group_id_with_access(&mut self, name: &str, min_level: GroupAccessLevel) -> ResultBoxError<GroupID> {
let group_id = self.post_group_id(name)?;
let access_level = groups_helper::get_access_level(&group_id, self.user_id_opt())?;
// TODO : add security checks
println!("Curr access level: {:?} / Expected: {:?}", access_level, min_level);
Ok(group_id)
}