(
State(state): State<Arc<ServerState>>,
Path(id): Path<String>,
Json(req): Json<OAuthCallbackRequest>,
)
| 2377 | } |
| 2378 | |
| 2379 | async fn oauth_callback( |
| 2380 | State(state): State<Arc<ServerState>>, |
| 2381 | Path(id): Path<String>, |
| 2382 | Json(req): Json<OAuthCallbackRequest>, |
| 2383 | ) -> Result<Json<bool>> { |
| 2384 | let loader = get_plugin_loader() |
| 2385 | .ok_or_else(|| ApiError::NotFound("no plugin loader initialized".to_string()))?; |
| 2386 | ProviderAuth::new(state.auth_manager.clone()) |
| 2387 | .callback(loader, &id, req.code.as_deref()) |
| 2388 | .await |
| 2389 | .map_err(|e| ApiError::BadRequest(e.to_string()))?; |
| 2390 | |
| 2391 | // Refresh auth loader state after callback and apply custom-fetch proxy changes immediately. |
| 2392 | if let Some(bridge) = loader.auth_bridge(&id).await { |
| 2393 | match bridge.load().await { |
| 2394 | Ok(load_result) => { |
| 2395 | crate::server::sync_custom_fetch_proxy(&id, bridge, load_result.has_custom_fetch); |
| 2396 | } |
| 2397 | Err(error) => { |
| 2398 | crate::server::sync_custom_fetch_proxy(&id, bridge, false); |
| 2399 | tracing::warn!( |
| 2400 | provider = %id, |
| 2401 | %error, |
| 2402 | "failed to refresh plugin auth loader after oauth callback" |
| 2403 | ); |
| 2404 | } |
| 2405 | } |
| 2406 | } |
| 2407 | |
| 2408 | Ok(Json(true)) |
| 2409 | } |
| 2410 | |
| 2411 | fn config_routes() -> Router<Arc<ServerState>> { |
| 2412 | Router::new() |
nothing calls this directly
no test coverage detected