this repo has no description
1use axum::{ 2 Json, 3 extract::State, 4 http::{HeaderMap, StatusCode}, 5 response::{IntoResponse, Response}, 6}; 7use serde::Serialize; 8use serde_json::json; 9use crate::auth::{extract_bearer_token_from_header, validate_bearer_token}; 10use crate::state::AppState; 11#[derive(Serialize)] 12#[serde(rename_all = "camelCase")] 13pub struct CheckSignupQueueOutput { 14 pub activated: bool, 15 #[serde(skip_serializing_if = "Option::is_none")] 16 pub place_in_queue: Option<i64>, 17 #[serde(skip_serializing_if = "Option::is_none")] 18 pub estimated_time_ms: Option<i64>, 19} 20pub async fn check_signup_queue( 21 State(state): State<AppState>, 22 headers: HeaderMap, 23) -> Response { 24 if let Some(token) = extract_bearer_token_from_header( 25 headers.get("Authorization").and_then(|h| h.to_str().ok()) 26 ) { 27 if let Ok(user) = validate_bearer_token(&state.db, &token).await { 28 if user.is_oauth { 29 return ( 30 StatusCode::FORBIDDEN, 31 Json(json!({ 32 "error": "Forbidden", 33 "message": "OAuth credentials are not supported for this endpoint" 34 })), 35 ).into_response(); 36 } 37 } 38 } 39 Json(CheckSignupQueueOutput { 40 activated: true, 41 place_in_queue: None, 42 estimated_time_ms: None, 43 }).into_response() 44}