1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-09-25 22:29:45 +00:00

Start to implement admin roles logic

This commit is contained in:
2021-05-14 18:25:53 +02:00
parent 57a5752fe7
commit 73837553c7
8 changed files with 182 additions and 23 deletions

View File

@@ -64,6 +64,7 @@ pub mod database_tables_names {
/// Administrators tables
pub const ADMIN_LIST_TABLE: &str = "comunic_admin";
pub const ADMIN_KEYS_TABLE: &str = "comunic_admin_key";
pub const ADMIN_ROLES_TABLE: &str = "comunic_admin_roles";
}
/// Push Notifications Database prefix
@@ -259,4 +260,43 @@ pub mod accounts_info_policy {
}
/// Url where Firebase push notifications can be sent
pub const FIREBASE_PUSH_MESSAGE_URL: &str = "https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send";
pub const FIREBASE_PUSH_MESSAGE_URL: &str = "https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send";
/// Admin-specific constants
pub mod admin {
#[derive(Copy, Clone, Eq, PartialEq)]
#[allow(non_camel_case_types)]
pub enum AdminRole {
MANAGE_ADMINS,
MANAGE_USERS,
ACCESS_FULL_ADMIN_LOGS,
}
pub struct AdminRoleMetadata {
pub role: AdminRole,
pub id: &'static str,
pub name: &'static str,
pub description: &'static str,
}
pub const ADMIN_ROLES_LIST: [AdminRoleMetadata; 3] = [
AdminRoleMetadata {
role: AdminRole::MANAGE_ADMINS,
id: "manage_admins",
name: "Manage administrators",
description: "Allow the admin to create, list and update all administrators",
},
AdminRoleMetadata {
role: AdminRole::MANAGE_USERS,
id: "manage_users",
name: "Manage Comunic users",
description: "Allow the admin to list, reset password and delete Comunic users",
},
AdminRoleMetadata {
role: AdminRole::ACCESS_FULL_ADMIN_LOGS,
id: "access_full_admin_logs",
name: "Access full admin logs",
description: "Allow the admin to access the action history of all admins",
}
];
}