mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-26 19:36:01 +03:00
feat: migrate username exists to use db_* interface
This commit is contained in:
parent
3a80281e86
commit
1cd4ce7318
2 changed files with 2 additions and 76 deletions
|
@ -169,21 +169,6 @@
|
|||
},
|
||||
"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": [
|
||||
|
@ -387,20 +372,6 @@
|
|||
},
|
||||
"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": [
|
||||
|
@ -536,26 +507,6 @@
|
|||
},
|
||||
"query": "SELECT name FROM mcaptcha_config \n WHERE key = $1 \n AND user_id = (\n SELECT user_id FROM mcaptcha_users WHERE NAME = $2)"
|
||||
},
|
||||
"ad23588ee4bcbb13e208460ce21e2fa9f1373893934b530b339fea10360b34a8": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "exists",
|
||||
"ordinal": 0,
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
null
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE name = $1)"
|
||||
},
|
||||
"ada91fac02c7bba9b13deebccda6f6fc45773b5a6e786c37c27b4a71a5cd29f2": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
|
@ -669,18 +620,6 @@
|
|||
},
|
||||
"query": "SELECT time FROM mcaptcha_pow_fetched_stats\n WHERE \n config_id = (\n SELECT \n 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"
|
||||
},
|
||||
"ca9d5241f1234d1825f7ead391ebe9099fca776e7101ac6e1761881606def5fa": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "DELETE FROM mcaptcha_users WHERE name = ($1)"
|
||||
},
|
||||
"d85750d86bbafeaf6f52cec3d49d708bef1a9ef85bbd9c55d63c9c27cb93223c": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
|
|
|
@ -40,22 +40,9 @@ pub mod runners {
|
|||
payload: &AccountCheckPayload,
|
||||
data: &AppData,
|
||||
) -> ServiceResult<AccountCheckResp> {
|
||||
let res = sqlx::query!(
|
||||
"SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE name = $1)",
|
||||
&payload.val,
|
||||
)
|
||||
.fetch_one(&data.db)
|
||||
.await?;
|
||||
let exists = data.dblib.username_exists(&payload.val).await?;
|
||||
|
||||
let mut resp = AccountCheckResp { exists: false };
|
||||
|
||||
if let Some(x) = res.exists {
|
||||
if x {
|
||||
resp.exists = true;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(resp)
|
||||
Ok(AccountCheckResp { exists })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue