24 řádky
602 B
Rust
Spustitelný soubor
24 řádky
602 B
Rust
Spustitelný soubor
use actix_web::{post, web::Data, HttpRequest, HttpResponse};
|
|
|
|
use crate::{ctx::Ctx, error::NekrochanError, web::tcx::account_from_auth};
|
|
|
|
#[post("/staff/actions/delete-account")]
|
|
pub async fn delete_account(
|
|
ctx: Data<Ctx>,
|
|
req: HttpRequest,
|
|
) -> Result<HttpResponse, NekrochanError> {
|
|
let account = account_from_auth(&ctx, &req).await?;
|
|
|
|
if account.perms().owner() {
|
|
return Err(NekrochanError::OwnerDeletionError);
|
|
}
|
|
|
|
account.delete(&ctx).await?;
|
|
|
|
let res = HttpResponse::SeeOther()
|
|
.append_header(("Location", "/logout"))
|
|
.finish();
|
|
|
|
Ok(res)
|
|
}
|