Automatically remove outdated account creation requests

This commit is contained in:
2023-05-31 11:06:58 +02:00
parent 62a52b385e
commit 7f8e41b618
4 changed files with 26 additions and 3 deletions

View File

@ -31,6 +31,9 @@ pub async fn create_account(remote_ip: RemoteIP, req: web::Json<CreateAccountBod
return Ok(HttpResponse::BadRequest().json("Size constraints were not respected!"));
}
// Perform cleanup
users_service::delete_not_validated_accounts().await?;
// Check if email is already attached to an account
if users_service::exists_email(&req.email).await? {
return Ok(
@ -44,8 +47,6 @@ pub async fn create_account(remote_ip: RemoteIP, req: web::Json<CreateAccountBod
// Trigger reset password (send mail)
users_service::request_reset_password(&mut user).await?;
// TODO : cleanup in a cron not validated accounts after 24 hours
// Account successfully created
Ok(HttpResponse::Created().finish())
}