From ad314fc81afcaaab32ef26d4cb47adc3352b3235 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Thu, 19 Dec 2024 12:56:26 -0600 Subject: [PATCH] Add auth check route --- src/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main.rs b/src/main.rs index d29d407..f742848 100644 --- a/src/main.rs +++ b/src/main.rs @@ -83,6 +83,10 @@ async fn main() -> anyhow::Result<()> { let app: Router = Router::new() .route("/auth/github", get(github_auth)) .route("/auth/github/callback", get(github_callback)) + .route( + "/auth/check", + get(auth_check).route_layer(middleware::from_fn(auth_middleware)), + ) .route( "/api/onchain", post(onchain_handler).route_layer(middleware::from_fn(auth_middleware)), @@ -285,6 +289,17 @@ async fn github_callback( ))) } +#[axum::debug_handler] +async fn auth_check( + Extension(_state): Extension, + Extension(user): Extension, +) -> Result, AppError> { + if is_banned(&user) { + return Err(AppError::new("You are banned")); + } + Ok(Json(json!({"status": "OK"}))) +} + #[axum::debug_handler] async fn onchain_handler( Extension(state): Extension,