tangled
alpha
login
or
join now
baileytownsend.dev
/
pds-gatekeeper
89
fork
atom
Microservice to bring 2FA to self hosted PDSes
89
fork
atom
overview
issues
1
pulls
3
pipelines
direct look up
baileytownsend.dev
3 weeks ago
39bbb78c
816f6517
+27
-9
2 changed files
expand all
collapse all
unified
split
html_templates
admin
accounts.hbs
src
admin
routes.rs
+4
-3
html_templates/admin/accounts.hbs
reviewed
···
21
21
<button type="submit" class="btn btn-primary">Search</button>
22
22
</form>
23
23
24
24
-
<form class="search-form" method="GET" action="/admin/account">
25
25
-
<input type="text" name="q" placeholder="Direct lookup by did or handle" value="{{search_query}}"/>
26
26
-
<button type="submit" class="btn btn-primary">Search</button>
24
24
+
<form class="search-form" method="GET" action="/admin/accounts/lookup">
25
25
+
<input type="text" name="direct_lookup" placeholder="Direct lookup by did or handle"
26
26
+
value="{{search_query}}"/>
27
27
+
<button type="submit" class="btn btn-primary">Lookup</button>
27
28
</form>
28
29
29
30
+23
-6
src/admin/routes.rs
reviewed
···
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
382
-
let handle = Handle::new(&look_up_did).unwrap();
382
382
+
let handle = match Handle::new(&look_up_did) {
383
383
+
Ok(h) => h,
384
384
+
Err(e) => {
385
385
+
tracing::warn!("Invalid handle '{}': {}", look_up_did, e);
386
386
+
return flash_redirect(
387
387
+
"/admin/accounts",
388
388
+
None,
389
389
+
Some(&format!("Invalid handle '{}': {}", look_up_did, e)),
390
390
+
);
391
391
+
}
392
392
+
};
383
393
let client = BasicClient::unauthenticated();
384
394
385
385
-
// Resolve handle to DID
386
386
-
println!("Resolving handle: {}", handle);
387
387
-
let did = client.resolve_handle(&handle).await.unwrap();
388
388
-
389
389
-
look_up_did = did.to_string()
395
395
+
tracing::debug!("Resolving handle: {}", handle);
396
396
+
look_up_did = match client.resolve_handle(&handle).await {
397
397
+
Ok(did) => did.to_string(),
398
398
+
Err(e) => {
399
399
+
tracing::warn!("Failed to resolve handle '{}': {}", handle, e);
400
400
+
return flash_redirect(
401
401
+
"/admin/accounts",
402
402
+
None,
403
403
+
Some(&format!("Could not resolve handle '{}': {}", handle, e)),
404
404
+
);
405
405
+
}
406
406
+
};
390
407
}
391
408
392
409
// Fetch account info, subject status, repo description, and repo status in parallel