demo user task

This commit is contained in:
realaravinth
2021-08-09 11:56:25 +05:30
parent 3c72d27b36
commit 147f563ec8
18 changed files with 190 additions and 72 deletions

View File

@@ -47,9 +47,7 @@ async fn delete_account(
match rec {
Ok(s) => {
if Config::verify(&s.password, &payload.password)? {
sqlx::query!("DELETE FROM mcaptcha_users WHERE name = ($1)", &username)
.execute(&data.db)
.await?;
runners::delete_user(&username, &data).await?;
id.forget();
Ok(HttpResponse::Ok())
} else {
@@ -61,6 +59,18 @@ async fn delete_account(
}
}
pub mod runners {
use super::*;
pub async fn delete_user(name: &str, data: &AppData) -> ServiceResult<()> {
sqlx::query!("DELETE FROM mcaptcha_users WHERE name = ($1)", name,)
.execute(&data.db)
.await?;
Ok(())
}
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(delete_account);
}

View File

@@ -114,7 +114,7 @@ pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
mod tests {
use super::*;
use actix_web::http::{header, StatusCode};
use actix_web::http::StatusCode;
use actix_web::test;
use crate::api::v1::ROUTES;

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use actix_web::http::{header, StatusCode};
use actix_web::http::StatusCode;
use actix_web::test;
use super::email::*;