feat: implement update_captcha_key for sqlx postgres

This commit is contained in:
realaravinth 2022-05-12 20:19:08 +05:30
parent e2ebae6e2e
commit b2d32c6113
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88

View file

@ -317,6 +317,26 @@ impl MCDatabase for Database {
Ok(())
}
/// update captcha key; doesn't change metadata
async fn update_captcha_key(
&self,
username: &str,
old_key: &str,
new_key: &str,
) -> DBResult<()> {
sqlx::query!(
"UPDATE mcaptcha_config SET key = $1
WHERE key = $2 AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = $3)",
new_key,
old_key,
username,
)
.execute(&self.pool)
.await
.map_err(map_register_err)?;
Ok(())
}
/// Add levels to captcha
async fn add_captcha_levels(
&self,