mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-26 19:36:01 +03:00
feat: migrate account deletion to use db_* interface
This commit is contained in:
parent
5dc818a1c1
commit
9f91854c4d
3 changed files with 32 additions and 5 deletions
|
@ -169,6 +169,21 @@
|
|||
},
|
||||
"query": "SELECT time FROM mcaptcha_pow_confirmed_stats \n WHERE \n config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n key = $1\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = $2))\n ORDER BY time DESC"
|
||||
},
|
||||
"45d9e9fb6344fe3a18c2529d50c935d3837bfe25c96595beb6970d6067720578": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Varchar"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "insert into mcaptcha_users \n (name , password, email, secret) values ($1, $2, $3, $4)"
|
||||
},
|
||||
"47fa50aecfb1499b0a18fa9299643017a1a8d69d4e9980032e0d8f745465d14f": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
|
@ -372,6 +387,20 @@
|
|||
},
|
||||
"query": "DELETE FROM mcaptcha_levels \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where key = ($1) \n AND user_id = (\n SELECT ID from mcaptcha_users WHERE name = $2\n )\n )"
|
||||
},
|
||||
"81c779ed4bb59f8b94dea730cbda31f7733ef16d509a3ed607388b5ddef74638": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES ($1, $2, $3)"
|
||||
},
|
||||
"84484cb6892db29121816bc5bff5702b9e857e20aa14e79d080d78ae7593153b": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
|
|
|
@ -64,9 +64,7 @@ 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?;
|
||||
data.dblib.delete_user(name).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,11 +197,11 @@ impl From<CredsError> for ServiceError {
|
|||
impl From<DBError> for ServiceError {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
fn from(e: DBError) -> ServiceError {
|
||||
match e{
|
||||
match e {
|
||||
DBError::UsernameTaken => ServiceError::UsernameTaken,
|
||||
DBError::SecretTaken => ServiceError::InternalServerError,
|
||||
DBError::EmailTaken => ServiceError::EmailTaken,
|
||||
_ => ServiceError::DBError(DBErrorWrapper(e))
|
||||
_ => ServiceError::DBError(DBErrorWrapper(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue