diff options
Diffstat (limited to 'src/auth/credentials.rs')
-rw-r--r-- | src/auth/credentials.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/auth/credentials.rs b/src/auth/credentials.rs index 88253b3..2ba3f29 100644 --- a/src/auth/credentials.rs +++ b/src/auth/credentials.rs @@ -9,6 +9,7 @@ use axum::{ }; use axum_extra::routing::Resource; use serde::{Deserialize, Serialize}; +use sqlx::PgPool; use uuid::Uuid; use crate::state::AppState; @@ -28,7 +29,7 @@ pub fn router() -> Resource<AppState> { } pub async fn create( - State(state): State<AppState>, + State(pool): State<PgPool>, Json(Credential { password }): Json<Credential>, ) -> Result<(StatusCode, (AccessClaims, RefreshClaims)), Error> { let salt = SaltString::generate(&mut OsRng); @@ -38,7 +39,7 @@ pub async fn create( "INSERT INTO credential (password_hash) VALUES ($1) RETURNING id", password_hash.to_string() ) - .fetch_optional(&state.pool) + .fetch_optional(&pool) .await? .ok_or(Error::Registration)? .id; @@ -49,8 +50,8 @@ pub async fn create( Ok((StatusCode::CREATED, (access, refresh))) } -pub async fn destroy(State(state): State<AppState>, Path(uuid): Path<Uuid>) -> Result<(), Error> { - let mut tx = state.pool.begin().await?; +pub async fn destroy(State(pool): State<PgPool>, Path(uuid): Path<Uuid>) -> Result<(), Error> { + let mut tx = pool.begin().await?; let rows = sqlx::query!("DELETE FROM credential WHERE id = $1", uuid) .execute(&mut *tx) .await? |