Microservice to bring 2FA to self hosted PDSes

direct look up

+27 -9
+4 -3
html_templates/admin/accounts.hbs
··· 21 21 <button type="submit" class="btn btn-primary">Search</button> 22 22 </form> 23 23 24 - <form class="search-form" method="GET" action="/admin/account"> 25 - <input type="text" name="q" placeholder="Direct lookup by did or handle" value="{{search_query}}"/> 26 - <button type="submit" class="btn btn-primary">Search</button> 24 + <form class="search-form" method="GET" action="/admin/accounts/lookup"> 25 + <input type="text" name="direct_lookup" placeholder="Direct lookup by did or handle" 26 + value="{{search_query}}"/> 27 + <button type="submit" class="btn btn-primary">Lookup</button> 27 28 </form> 28 29 29 30
+23 -6
src/admin/routes.rs
··· 379 379 let mut look_up_did: String = params.direct_lookup.unwrap_or_else(|| did); 380 380 381 381 if !look_up_did.starts_with("did") { 382 - let handle = Handle::new(&look_up_did).unwrap(); 382 + let handle = match Handle::new(&look_up_did) { 383 + Ok(h) => h, 384 + Err(e) => { 385 + tracing::warn!("Invalid handle '{}': {}", look_up_did, e); 386 + return flash_redirect( 387 + "/admin/accounts", 388 + None, 389 + Some(&format!("Invalid handle '{}': {}", look_up_did, e)), 390 + ); 391 + } 392 + }; 383 393 let client = BasicClient::unauthenticated(); 384 394 385 - // Resolve handle to DID 386 - println!("Resolving handle: {}", handle); 387 - let did = client.resolve_handle(&handle).await.unwrap(); 388 - 389 - look_up_did = did.to_string() 395 + tracing::debug!("Resolving handle: {}", handle); 396 + look_up_did = match client.resolve_handle(&handle).await { 397 + Ok(did) => did.to_string(), 398 + Err(e) => { 399 + tracing::warn!("Failed to resolve handle '{}': {}", handle, e); 400 + return flash_redirect( 401 + "/admin/accounts", 402 + None, 403 + Some(&format!("Could not resolve handle '{}': {}", handle, e)), 404 + ); 405 + } 406 + }; 390 407 } 391 408 392 409 // Fetch account info, subject status, repo description, and repo status in parallel