if access token expired, use refresh token, and get new access + refresh tokens
This commit is contained in:
parent
9172155893
commit
8db0bbb874
12 changed files with 462 additions and 41 deletions
|
|
@ -71,4 +71,17 @@ impl RefreshTokens {
|
|||
|
||||
Ok((query.rows_affected() >= 1).then_some(()))
|
||||
}
|
||||
|
||||
pub async fn use_token(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
token: &str,
|
||||
) -> Result<Option<()>, Error> {
|
||||
let query: SqliteQueryResult =
|
||||
sqlx::query_file!("queries/refresh_tokens/use_token.sql", token)
|
||||
.execute(conn)
|
||||
.await
|
||||
.map_err(handle_error)?;
|
||||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,4 +85,14 @@ impl Users {
|
|||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn get_one_from_refresh_token(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
token: &str,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
sqlx::query_file_as!(Self, "queries/users/get_one_from_refresh_token.sql", token)
|
||||
.fetch_optional(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue