forgot password: email and paper key, reset password
This commit is contained in:
parent
6ddbe013bc
commit
751a21485f
21 changed files with 688 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::error::Error;
|
||||
use crate::password_reset::PasswordResetToken;
|
||||
use crate::User;
|
||||
use database::sqlx::SqliteExecutor;
|
||||
use database::Error as DatabaseError;
|
||||
|
|
@ -53,7 +54,7 @@ impl User {
|
|||
.map(Self::from))
|
||||
}
|
||||
|
||||
async fn get_by_email(
|
||||
pub async fn get_by_email(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
email: &EmailAddress,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
|
|
@ -108,6 +109,17 @@ impl User {
|
|||
.map(Self::from))
|
||||
}
|
||||
|
||||
pub async fn get_one_from_password_reset_token(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
token: &PasswordResetToken,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
Ok(
|
||||
DatabaseUsers::get_one_from_password_reset_token(conn, token.to_string().as_str())
|
||||
.await?
|
||||
.map(Self::from),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn get_all(conn: impl SqliteExecutor<'_>) -> Result<Vec<Self>, Error> {
|
||||
Ok(DatabaseUsers::get_all(conn)
|
||||
.await?
|
||||
|
|
@ -198,4 +210,19 @@ impl User {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_password_reset_token(
|
||||
&self,
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
token: Option<&PasswordResetToken>,
|
||||
) -> Result<(), Error> {
|
||||
DatabaseUsers::set_password_reset_token(
|
||||
conn,
|
||||
self.id.as_ref(),
|
||||
token.map(|t| t.to_string()).as_deref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue