mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-13 02:55:39 +00:00
using custom version of actix-codegen and cors for pow routes
This commit is contained in:
@@ -22,6 +22,7 @@ use super::auth::Password;
|
||||
use crate::errors::*;
|
||||
use crate::Data;
|
||||
|
||||
#[my_codegen::post(path="crate::V1_API_ROUTES.account.delete", wrap="crate::CheckLogin")]
|
||||
async fn delete_account(
|
||||
id: Identity,
|
||||
payload: web::Json<Password>,
|
||||
@@ -59,13 +60,14 @@ async fn delete_account(
|
||||
}
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
use crate::define_resource;
|
||||
use crate::V1_API_ROUTES;
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.delete,
|
||||
Methods::ProtectPost,
|
||||
delete_account
|
||||
);
|
||||
cfg.service(delete_account);
|
||||
// use crate::define_resource;
|
||||
// use crate::V1_API_ROUTES;
|
||||
//
|
||||
// define_resource!(
|
||||
// cfg,
|
||||
// V1_API_ROUTES.account.delete,
|
||||
// Methods::ProtectPost,
|
||||
// delete_account
|
||||
// );
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ pub struct Email {
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
#[my_codegen::post(path="crate::V1_API_ROUTES.account.email_exists")]
|
||||
pub async fn email_exists(
|
||||
payload: web::Json<AccountCheckPayload>,
|
||||
data: web::Data<Data>,
|
||||
@@ -52,6 +53,7 @@ pub async fn email_exists(
|
||||
}
|
||||
|
||||
/// update email
|
||||
#[my_codegen::post(path="crate::V1_API_ROUTES.account.update_email", wrap="crate::CheckLogin")]
|
||||
async fn set_email(
|
||||
id: Identity,
|
||||
payload: web::Json<Email>,
|
||||
@@ -84,20 +86,22 @@ async fn set_email(
|
||||
}
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
use crate::define_resource;
|
||||
use crate::V1_API_ROUTES;
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.email_exists,
|
||||
Methods::Post,
|
||||
email_exists
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.update_email,
|
||||
Methods::Post,
|
||||
set_email
|
||||
);
|
||||
cfg.service(email_exists);
|
||||
cfg.service(set_email);
|
||||
// use crate::define_resource;
|
||||
// use crate::V1_API_ROUTES;
|
||||
//
|
||||
// define_resource!(
|
||||
// cfg,
|
||||
// V1_API_ROUTES.account.email_exists,
|
||||
// Methods::Post,
|
||||
// email_exists
|
||||
// );
|
||||
//
|
||||
// define_resource!(
|
||||
// cfg,
|
||||
// V1_API_ROUTES.account.update_email,
|
||||
// Methods::Post,
|
||||
// set_email
|
||||
// );
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ pub struct Secret {
|
||||
pub secret: String,
|
||||
}
|
||||
|
||||
#[my_codegen::get(path="crate::V1_API_ROUTES.account.get_secret", wrap="crate::CheckLogin")]
|
||||
async fn get_secret(
|
||||
id: Identity,
|
||||
data: web::Data<Data>,
|
||||
@@ -46,6 +47,7 @@ async fn get_secret(
|
||||
Ok(HttpResponse::Ok().json(secret))
|
||||
}
|
||||
|
||||
#[my_codegen::post(path="crate::V1_API_ROUTES.account.update_secret", wrap="crate::CheckLogin")]
|
||||
async fn update_user_secret(
|
||||
id: Identity,
|
||||
data: web::Data<Data>,
|
||||
@@ -82,20 +84,6 @@ async fn update_user_secret(
|
||||
}
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
use crate::define_resource;
|
||||
use crate::V1_API_ROUTES;
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.get_secret,
|
||||
Methods::ProtectGet,
|
||||
get_secret
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.update_secret,
|
||||
Methods::ProtectPost,
|
||||
update_user_secret
|
||||
);
|
||||
cfg.service(get_secret);
|
||||
cfg.service(update_user_secret);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use super::{AccountCheckPayload, AccountCheckResp};
|
||||
use crate::errors::*;
|
||||
use crate::Data;
|
||||
|
||||
#[my_codegen::post(path="crate::V1_API_ROUTES.account.username_exists")]
|
||||
async fn username_exists(
|
||||
payload: web::Json<AccountCheckPayload>,
|
||||
data: web::Data<Data>,
|
||||
@@ -43,13 +44,5 @@ async fn username_exists(
|
||||
}
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
use crate::define_resource;
|
||||
use crate::V1_API_ROUTES;
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.username_exists,
|
||||
Methods::Post,
|
||||
username_exists
|
||||
);
|
||||
cfg.service(username_exists);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user