feat: define interface for fetching user password

This commit is contained in:
realaravinth 2022-05-11 15:43:03 +05:30
parent 78eac8b6b7
commit 6377d07dce
No known key found for this signature in database
GPG Key ID: AD9F0F08E855ED88
2 changed files with 9 additions and 0 deletions

View File

@ -101,6 +101,9 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
/// update a user's email
async fn update_email(&self, p: &UpdateEmail) -> DBResult<()>;
/// get a user's password
async fn get_password(&self, username: &str) -> DBResult<String>;
}
/// Trait to clone MCDatabase

View File

@ -28,6 +28,12 @@ pub async fn database_works<'a, T: MCDatabase>(db: &T, p: &Register<'a>) {
);
}
db.register(p).await.unwrap();
assert_eq!(
db.get_password(p.username).await.unwrap(),
p.hash,
"user password matches"
);
assert!(
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
"user is registered so email should exsit"