Skip to content

Commit

Permalink
Add auth check route
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Dec 19, 2024
1 parent 530a6e0 commit ad314fc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -285,6 +289,17 @@ async fn github_callback(
)))
}

#[axum::debug_handler]
async fn auth_check(
Extension(_state): Extension<AppState>,
Extension(user): Extension<AuthUser>,
) -> Result<Json<Value>, 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<AppState>,
Expand Down

0 comments on commit ad314fc

Please sign in to comment.