mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-27 03:48:52 +03:00
feat: migrate email exists to use db_* interface
This commit is contained in:
parent
84671c4a11
commit
621e400ea8
2 changed files with 2 additions and 33 deletions
|
@ -169,26 +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"
|
"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"
|
||||||
},
|
},
|
||||||
"47fa50aecfb1499b0a18fa9299643017a1a8d69d4e9980032e0d8f745465d14f": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "exists",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nullable": [
|
|
||||||
null
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE email = $1)"
|
|
||||||
},
|
|
||||||
"4a5dfbc5aeb2bab290a09640cc25223d484fbc7549e5bc54f33bab8616725031": {
|
"4a5dfbc5aeb2bab290a09640cc25223d484fbc7549e5bc54f33bab8616725031": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
|
|
@ -34,20 +34,9 @@ pub async fn email_exists(
|
||||||
payload: web::Json<AccountCheckPayload>,
|
payload: web::Json<AccountCheckPayload>,
|
||||||
data: AppData,
|
data: AppData,
|
||||||
) -> ServiceResult<impl Responder> {
|
) -> ServiceResult<impl Responder> {
|
||||||
let res = sqlx::query!(
|
let exists = data.dblib.email_exists(&payload.val).await?;
|
||||||
"SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE email = $1)",
|
|
||||||
&payload.val,
|
|
||||||
)
|
|
||||||
.fetch_one(&data.db)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let mut resp = AccountCheckResp { exists: false };
|
let resp = AccountCheckResp { exists };
|
||||||
|
|
||||||
if let Some(x) = res.exists {
|
|
||||||
if x {
|
|
||||||
resp.exists = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().json(resp))
|
Ok(HttpResponse::Ok().json(resp))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue