mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-03 22:45:01 +00:00
Can update admin roles
This commit is contained in:
@ -12,6 +12,7 @@ use image::{GenericImageView, ImageFormat};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::api_data::http_error::HttpError;
|
||||
use crate::constants::admin::AdminRole;
|
||||
use crate::constants::PASSWORD_MIN_LENGTH;
|
||||
use crate::data::admin::AdminID;
|
||||
use crate::data::comment::Comment;
|
||||
@ -24,7 +25,7 @@ use crate::data::group_id::GroupID;
|
||||
use crate::data::post::{Post, PostAccessLevel};
|
||||
use crate::data::user::UserID;
|
||||
use crate::data::user_token::UserAccessToken;
|
||||
use crate::helpers::{account_helper, admin_account_helper, comments_helper, conversations_helper, custom_emojies_helper, friends_helper, groups_helper, posts_helper, user_helper, virtual_directory_helper};
|
||||
use crate::helpers::{account_helper, admin_account_helper, admin_roles_helper, comments_helper, conversations_helper, custom_emojies_helper, friends_helper, groups_helper, posts_helper, user_helper, virtual_directory_helper};
|
||||
use crate::helpers::virtual_directory_helper::VirtualDirType;
|
||||
use crate::routes::RequestResult;
|
||||
use crate::utils::mp3_utils::is_valid_mp3;
|
||||
@ -606,6 +607,15 @@ pub trait BaseRequestHandler {
|
||||
Ok(admin_id)
|
||||
}
|
||||
|
||||
/// Check if an admin has a given role or not
|
||||
fn check_admin_has_role(&mut self, role: AdminRole) -> Res {
|
||||
if !admin_roles_helper::has_role(self.admin_id()?, role)? {
|
||||
self.forbidden("You have not the permission to do this!".to_string())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get a list of users ID included in the request
|
||||
fn post_users_id(&mut self, name: &str) -> ResultBoxError<HashSet<UserID>> {
|
||||
let users = self.post_numbers_list(name, 1)?
|
||||
|
Reference in New Issue
Block a user