diff --git a/core/bild.db b/core/bild.db new file mode 100644 index 0000000000000000000000000000000000000000..3354a9cbaea3563c8e4745b7bf03fc012fd004fc GIT binary patch literal 16384 zcmWCy^vNtqRY=P(%1ta$FlG>7U}R))P*7lCU|?imU|?ZD0Bn4OEOr(ngI-kuFaHk) zX1;m`zKi_l`RcJN92Ff6fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@R7}g;Wz|1DD zt<4x&l9-f}T3ncuS&|xGoLX3#nwN~uWpNI2bqsM;2yt}saaBN5tC5$Oo2pZsTBzAr z&B!h;D$3XlF*7^0vKWM!P;`St6g0RLaDdDd1y8>aS9jMSg@7PWU&o+G1#j0#1;@}3 ze@{Q>AXi^kzYraqx>GV!6hd4hLKOV`Llpc%eSB~$%}%W(R%xi8XJDwSMoMOijzV^7 zr6yMEHPxBe#H~dc88Y)yQY)ZglvrAl59Y^%yd7@{BAFQ&7&t&Fix)%)fQV5%8Umvs zFd71*Aut*OqaiRF0;3@?8UmvsFd71*Aut*OqaiR{Lx2n9vC;lNC=^EVXb6mkz-S1J zhQMeDjE2By2#kinXb6mkz-S1JhQMeD4BHSGo&O)UQ9J6f(GVC7fzc2c4S~@R7!85Z Y5Eu=C(GVC7fzc2c4S~@R01O@i028oliU0rr literal 0 HcmV?d00001 diff --git a/core/src/routes.rs b/core/src/routes.rs index 2445e3e..56c6b9a 100644 --- a/core/src/routes.rs +++ b/core/src/routes.rs @@ -1,10 +1,15 @@ pub mod login { + use crate::AppState; use atrium_api::{ agent::{AtpAgent, store::MemorySessionStore}, types::string::AtIdentifier, }; use atrium_xrpc_client::isahc::IsahcClient; - use axum::{extract::Form, http::StatusCode, response::IntoResponse}; + use axum::{ + extract::{Form, State}, + http::StatusCode, + response::IntoResponse, + }; use serde::Deserialize; pub async fn get() -> String { @@ -17,9 +22,14 @@ pub mod login { app_password: String, } - pub async fn post(session: tower_sessions::Session, Form(req): Form) -> impl IntoResponse { + pub async fn post( + State(state): State, + session: tower_sessions::Session, + Form(req): Form, + ) -> impl IntoResponse { + let did_doc = state.resolve_did_document(&req.handle).await.unwrap(); let agent = AtpAgent::new( - IsahcClient::new("https://dummy.example"), + IsahcClient::new(did_doc.get_pds_endpoint().unwrap()), MemorySessionStore::default(), ); let res = agent.login(req.handle, req.app_password).await.unwrap(); @@ -31,10 +41,16 @@ pub mod login { } pub mod index { + use crate::AppState; use atrium_api::agent::{AtpAgent, store::MemorySessionStore}; + use atrium_api::types::string::AtIdentifier; use atrium_xrpc_client::isahc::IsahcClient; + use axum::extract::State; - pub async fn get(session: tower_sessions::Session) -> &'static str { + pub async fn get( + session: tower_sessions::Session, + State(state): State, + ) -> &'static str { match session .get::("bild_session") .await @@ -42,8 +58,12 @@ pub mod index { { None => "no session", Some(s) => { + let did_doc = state + .resolve_did_document(&AtIdentifier::Did(s.did.clone())) + .await + .unwrap(); let agent = AtpAgent::new( - IsahcClient::new("https://dummy.example"), + IsahcClient::new(did_doc.get_pds_endpoint().unwrap()), MemorySessionStore::default(), ); println!("resuming session of {:?} ({:?})", s.handle, s.did); @@ -123,7 +143,9 @@ pub mod keys { let did = sess.did.clone().into(); db.conn .call(|c| { - c.execute("INSERT INTO keys VALUES (?1, ?2)", [did, req.key])?; + c.execute("INSERT INTO keys (did, key) VALUES (?1, ?2)", [ + did, req.key, + ])?; Ok(()) }) .await