mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
using custom version of actix-codegen and cors for pow routes
This commit is contained in:
@@ -37,11 +37,8 @@ lazy_static! {
|
||||
static ref INDEX: String = IndexPage::default().render_once().unwrap();
|
||||
}
|
||||
|
||||
const ROUTE: &str = PAGES.auth.login;
|
||||
|
||||
#[get(path="ROUTE")]
|
||||
#[get(path="PAGES.auth.login")]
|
||||
pub async fn login() -> impl Responder {
|
||||
struct Foo;
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
.body(&*INDEX)
|
||||
|
||||
@@ -19,12 +19,8 @@ pub mod login;
|
||||
pub mod register;
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
use crate::define_resource;
|
||||
use crate::PAGES;
|
||||
|
||||
cfg.service(login::login);
|
||||
// define_resource!(cfg, PAGES.auth.login, Methods::Get, login::login);
|
||||
define_resource!(cfg, PAGES.auth.join, Methods::Get, register::join);
|
||||
cfg.service(register::join);
|
||||
}
|
||||
|
||||
pub mod routes {
|
||||
|
||||
@@ -35,6 +35,7 @@ lazy_static! {
|
||||
static ref INDEX: String = IndexPage::default().render_once().unwrap();
|
||||
}
|
||||
|
||||
#[my_codegen::get(path = "crate::PAGES.auth.join")]
|
||||
pub async fn join() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
|
||||
@@ -39,6 +39,7 @@ impl IndexPage {
|
||||
|
||||
const PAGE: &str = "Dashboard";
|
||||
|
||||
#[my_codegen::get(path = "crate::PAGES.panel.home", wrap = "crate::CheckLogin")]
|
||||
async fn panel(data: web::Data<Data>, id: Identity) -> PageResult<impl Responder> {
|
||||
let sitekeys = get_list_sitekeys(&data, &id).await?;
|
||||
let body = IndexPage::new(sitekeys).render_once().unwrap();
|
||||
@@ -48,10 +49,7 @@ async fn panel(data: web::Data<Data>, id: Identity) -> PageResult<impl Responder
|
||||
}
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
use crate::define_resource;
|
||||
use crate::PAGES;
|
||||
|
||||
define_resource!(cfg, PAGES.panel.home, Methods::ProtectGet, panel);
|
||||
cfg.service(panel);
|
||||
sitekey::services(cfg);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ impl<'a> Default for IndexPage<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[my_codegen::get(path = "crate::PAGES.panel.sitekey.add", wrap = "crate::CheckLogin")]
|
||||
pub async fn add_sitekey() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
|
||||
@@ -38,6 +38,7 @@ impl IndexPage {
|
||||
}
|
||||
|
||||
/// render a list of all sitekeys that a user has
|
||||
#[my_codegen::get(path = "crate::PAGES.panel.sitekey.list", wrap = "crate::CheckLogin")]
|
||||
pub async fn list_sitekeys(
|
||||
data: web::Data<Data>,
|
||||
id: Identity,
|
||||
|
||||
@@ -38,27 +38,7 @@ pub mod routes {
|
||||
}
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
use crate::define_resource;
|
||||
use crate::PAGES;
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
PAGES.panel.sitekey.add,
|
||||
Methods::ProtectGet,
|
||||
add::add_sitekey
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
PAGES.panel.sitekey.list,
|
||||
Methods::ProtectGet,
|
||||
list::list_sitekeys
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
PAGES.panel.sitekey.view,
|
||||
Methods::ProtectGet,
|
||||
view::view_sitekey
|
||||
);
|
||||
cfg.service(add::add_sitekey);
|
||||
cfg.service(list::list_sitekeys);
|
||||
cfg.service(view::view_sitekey);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ impl IndexPage {
|
||||
}
|
||||
|
||||
/// route handler that renders individual views for sitekeys
|
||||
#[my_codegen::get(path = "crate::PAGES.panel.sitekey.view", wrap = "crate::CheckLogin")]
|
||||
pub async fn view_sitekey(
|
||||
path: web::Path<String>,
|
||||
data: web::Data<Data>,
|
||||
|
||||
Reference in New Issue
Block a user