mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-23 01:45:50 +03:00
feat: define interface for checking if user email exists
This commit is contained in:
parent
136439c97a
commit
9595ea232b
2 changed files with 12 additions and 0 deletions
|
@ -86,6 +86,9 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||
|
||||
/// check if username exists
|
||||
async fn username_exists(&self, username: &str) -> DBResult<bool>;
|
||||
|
||||
/// check if email exists
|
||||
async fn email_exists(&self, email: &str) -> DBResult<bool>;
|
||||
}
|
||||
|
||||
/// Trait to clone MCDatabase
|
||||
|
|
|
@ -28,6 +28,10 @@ pub async fn database_works<'a, T: MCDatabase>(db: &T, p: &Register<'a>) {
|
|||
);
|
||||
}
|
||||
db.register(p).await.unwrap();
|
||||
assert!(
|
||||
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||
"user is registered so email should exsit"
|
||||
);
|
||||
assert!(
|
||||
db.username_exists(p.username).await.unwrap(),
|
||||
"user is registered so username should exsit"
|
||||
|
@ -46,4 +50,9 @@ pub async fn database_works<'a, T: MCDatabase>(db: &T, p: &Register<'a>) {
|
|||
db.username_exists(p2.username).await.unwrap(),
|
||||
"user is registered so username should exsit"
|
||||
);
|
||||
assert!(
|
||||
!db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||
"user registration with email is deleted; so email shouldn't exsit"
|
||||
);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue