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