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
|
|
@ -97,6 +97,20 @@ impl Users {
|
|||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn get_one_from_password_reset_token(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
token: &str,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
sqlx::query_file_as!(
|
||||
Self,
|
||||
"queries/users/get_one_from_password_reset_token.sql",
|
||||
token
|
||||
)
|
||||
.fetch_optional(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn get_all(conn: impl SqliteExecutor<'_>) -> Result<Vec<Self>, Error> {
|
||||
sqlx::query_file_as!(Self, "queries/users/get_all.sql")
|
||||
.fetch_all(conn)
|
||||
|
|
@ -185,4 +199,18 @@ impl Users {
|
|||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
|
||||
pub async fn set_password_reset_token(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
id: &str,
|
||||
token: Option<&str>,
|
||||
) -> Result<Option<()>, Error> {
|
||||
let query: SqliteQueryResult =
|
||||
sqlx::query_file!("queries/users/set_password_reset_token.sql", token, id)
|
||||
.execute(conn)
|
||||
.await
|
||||
.map_err(handle_error)?;
|
||||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue