mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
feat: define interfaces for delete_captcha_levels and delete_captcha
This commit is contained in:
@@ -151,6 +151,16 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||||||
username: Option<&str>,
|
username: Option<&str>,
|
||||||
captcha_key: &str,
|
captcha_key: &str,
|
||||||
) -> DBResult<bool>;
|
) -> DBResult<bool>;
|
||||||
|
|
||||||
|
/// Delete all levels of a captcha
|
||||||
|
async fn delete_captcha_levels(
|
||||||
|
&self,
|
||||||
|
username: &str,
|
||||||
|
captcha_key: &str,
|
||||||
|
) -> DBResult<()>;
|
||||||
|
|
||||||
|
/// Delete captcha
|
||||||
|
async fn delete_captcha(&self, username: &str, captcha_key: &str) -> DBResult<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
|||||||
@@ -131,8 +131,18 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
"user was with empty email but email is set; so email should exsit"
|
"user was with empty email but email is set; so email should exsit"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// create captcha
|
||||||
db.create_captcha(p.username, c).await.unwrap();
|
db.create_captcha(p.username, c).await.unwrap();
|
||||||
assert!(db.captcha_exists(None, c.key).await.unwrap());
|
assert!(db.captcha_exists(None, c.key).await.unwrap());
|
||||||
assert!(db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
assert!(db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
||||||
|
|
||||||
|
// add captcha levels
|
||||||
db.add_captcha_levels(p.username, c.key, l).await.unwrap();
|
db.add_captcha_levels(p.username, c.key, l).await.unwrap();
|
||||||
|
|
||||||
|
// delete captcha levels
|
||||||
|
db.delete_captcha_levels(p.username, c.key).await.unwrap();
|
||||||
|
|
||||||
|
// delete captcha
|
||||||
|
db.delete_captcha(p.username, c.key).await.unwrap();
|
||||||
|
assert!(!db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user