survey/src/api/v1/admin/mod.rs

50 lines
1.2 KiB
Rust
Raw Normal View History

2023-11-01 17:12:16 +05:30
// Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use actix_auth_middleware::*;
2021-10-11 13:41:36 +05:30
use actix_web::web::ServiceConfig;
pub mod account;
pub mod auth;
2021-10-11 13:57:07 +05:30
pub mod campaigns;
2021-10-11 13:41:36 +05:30
#[cfg(test)]
mod tests;
pub use super::{get_random, get_uuid, RedirectQuery};
2021-10-11 13:41:36 +05:30
pub fn services(cfg: &mut ServiceConfig) {
auth::services(cfg);
account::services(cfg);
2021-10-11 18:28:45 +05:30
campaigns::services(cfg);
2021-10-11 13:41:36 +05:30
}
pub fn get_admin_check_login() -> Authentication<auth::routes::Auth> {
Authentication::with_identity(super::ROUTES.admin.auth)
2021-10-11 13:41:36 +05:30
}
pub mod routes {
use super::account::routes::Account;
use super::auth::routes::Auth;
2021-10-11 13:57:07 +05:30
use super::campaigns::routes::Campaign;
use serde::Serialize;
2021-10-11 13:41:36 +05:30
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
2021-10-11 13:41:36 +05:30
pub struct Admin {
pub auth: Auth,
pub account: Account,
2021-10-11 13:57:07 +05:30
pub campaign: Campaign,
2021-10-11 13:41:36 +05:30
}
impl Admin {
pub const fn new() -> Admin {
Admin {
account: Account::new(),
auth: Auth::new(),
2021-10-11 13:57:07 +05:30
campaign: Campaign::new(),
2021-10-11 13:41:36 +05:30
}
}
}
}