diff options
Diffstat (limited to 'src/login/routes.rs')
| -rw-r--r-- | src/login/routes.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/login/routes.rs b/src/login/routes.rs index c30bcb1..9cefe38 100644 --- a/src/login/routes.rs +++ b/src/login/routes.rs @@ -5,16 +5,15 @@ use axum::{ routing::post, Router, }; -use sqlx::sqlite::SqlitePool; -use crate::{clock::RequestedAt, error::InternalError}; +use crate::{app::App, clock::RequestedAt, error::InternalError}; use super::{ extract::IdentityToken, repo::{logins::Provider as _, tokens::Provider as _}, }; -pub fn router() -> Router<SqlitePool> { +pub fn router() -> Router<App> { Router::new() .route("/login", post(on_login)) .route("/logout", post(on_logout)) @@ -27,12 +26,12 @@ struct LoginRequest { } async fn on_login( - State(db): State<SqlitePool>, + State(app): State<App>, RequestedAt(now): RequestedAt, identity: IdentityToken, Form(form): Form<LoginRequest>, ) -> Result<impl IntoResponse, InternalError> { - let mut tx = db.begin().await?; + let mut tx = app.db.begin().await?; // Spelling the following in the more conventional form, // if let Some(…) = create().await? {} @@ -88,11 +87,11 @@ impl IntoResponse for LoginResponse { } async fn on_logout( - State(db): State<SqlitePool>, + State(app): State<App>, identity: IdentityToken, ) -> Result<impl IntoResponse, InternalError> { if let Some(secret) = identity.secret() { - let mut tx = db.begin().await?; + let mut tx = app.db.begin().await?; tx.tokens().revoke(secret).await?; tx.commit().await?; } |
