ezidam: oauth: redirect: get and check code, get user info, mark code as used, display html template
This commit is contained in:
parent
719048e268
commit
827bba041a
15 changed files with 310 additions and 19 deletions
|
|
@ -37,4 +37,21 @@ impl AuthorizationCodes {
|
|||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
|
||||
pub async fn get_one(conn: impl SqliteExecutor<'_>, code: &str) -> Result<Option<Self>, Error> {
|
||||
sqlx::query_file_as!(Self, "queries/authorization_codes/get_one.sql", code)
|
||||
.fetch_optional(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn use_code(conn: impl SqliteExecutor<'_>, code: &str) -> Result<Option<()>, Error> {
|
||||
let query: SqliteQueryResult =
|
||||
sqlx::query_file!("queries/authorization_codes/use_code.sql", code)
|
||||
.execute(conn)
|
||||
.await
|
||||
.map_err(handle_error)?;
|
||||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,18 @@ impl Users {
|
|||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
|
||||
pub async fn get_one_from_authorization_code(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
code: &str,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
sqlx::query_file_as!(
|
||||
Self,
|
||||
"queries/users/get_one_from_authorization_code.sql",
|
||||
code
|
||||
)
|
||||
.fetch_optional(conn)
|
||||
.await
|
||||
.map_err(handle_error)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue