mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
cleanup
This commit is contained in:
@@ -22,8 +22,7 @@ use super::auth::Password;
|
||||
use crate::errors::*;
|
||||
use crate::Data;
|
||||
|
||||
//#[post("/api/v1/account/delete", wrap = "CheckLogin")]
|
||||
pub async fn delete_account(
|
||||
async fn delete_account(
|
||||
id: Identity,
|
||||
payload: web::Json<Password>,
|
||||
data: web::Data<Data>,
|
||||
@@ -58,3 +57,15 @@ pub async fn delete_account(
|
||||
Err(_) => return Err(ServiceError::InternalServerError)?,
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ pub struct Email {
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
//#[post("/api/v1/account/email/exists")]
|
||||
pub async fn email_exists(
|
||||
payload: web::Json<AccountCheckPayload>,
|
||||
data: web::Data<Data>,
|
||||
@@ -53,9 +52,7 @@ pub async fn email_exists(
|
||||
}
|
||||
|
||||
/// update email
|
||||
//#[post("/api/v1/account/email/", wrap = "CheckLogin")]
|
||||
//#[post("/api/v1/", wrap = "CheckLogin")]
|
||||
pub async fn set_email(
|
||||
async fn set_email(
|
||||
id: Identity,
|
||||
payload: web::Json<Email>,
|
||||
data: web::Data<Data>,
|
||||
@@ -85,3 +82,22 @@ pub async fn set_email(
|
||||
}
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,48 +69,8 @@ pub struct AccountCheckResp {
|
||||
}
|
||||
|
||||
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::delete_account
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.username_exists,
|
||||
Methods::Post,
|
||||
username::username_exists
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.email_exists,
|
||||
Methods::Post,
|
||||
email::email_exists
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.update_email,
|
||||
Methods::Post,
|
||||
email::set_email
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.get_secret,
|
||||
Methods::ProtectGet,
|
||||
secret::get_secret
|
||||
);
|
||||
|
||||
define_resource!(
|
||||
cfg,
|
||||
V1_API_ROUTES.account.update_secret,
|
||||
Methods::ProtectPost,
|
||||
secret::update_user_secret
|
||||
);
|
||||
delete::services(cfg);
|
||||
email::services(cfg);
|
||||
username::services(cfg);
|
||||
secret::services(cfg);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ pub struct Secret {
|
||||
pub secret: String,
|
||||
}
|
||||
|
||||
//#[get("/api/v1/account/secret/", wrap = "CheckLogin")]
|
||||
pub async fn get_secret(id: Identity, data: web::Data<Data>) -> ServiceResult<impl Responder> {
|
||||
async fn get_secret(id: Identity, data: web::Data<Data>) -> ServiceResult<impl Responder> {
|
||||
let username = id.identity().unwrap();
|
||||
|
||||
let secret = sqlx::query_as!(
|
||||
@@ -44,11 +43,7 @@ pub async fn get_secret(id: Identity, data: web::Data<Data>) -> ServiceResult<im
|
||||
Ok(HttpResponse::Ok().json(secret))
|
||||
}
|
||||
|
||||
//#[post("/api/v1/account/secret/", wrap = "CheckLogin")]
|
||||
pub async fn update_user_secret(
|
||||
id: Identity,
|
||||
data: web::Data<Data>,
|
||||
) -> ServiceResult<impl Responder> {
|
||||
async fn update_user_secret(id: Identity, data: web::Data<Data>) -> ServiceResult<impl Responder> {
|
||||
let username = id.identity().unwrap();
|
||||
|
||||
let mut secret;
|
||||
@@ -79,3 +74,22 @@ pub async fn update_user_secret(
|
||||
}
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ use super::{AccountCheckPayload, AccountCheckResp};
|
||||
use crate::errors::*;
|
||||
use crate::Data;
|
||||
|
||||
//#[post("/api/v1/account/username/exists")]
|
||||
pub async fn username_exists(
|
||||
async fn username_exists(
|
||||
payload: web::Json<AccountCheckPayload>,
|
||||
data: web::Data<Data>,
|
||||
) -> ServiceResult<impl Responder> {
|
||||
@@ -42,3 +41,15 @@ pub async fn username_exists(
|
||||
|
||||
Ok(HttpResponse::Ok().json(resp))
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user