about summary refs log tree commit diff
path: root/kittybox-rs/src/frontend/onboarding.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-09-28 03:55:48 +0300
committerVika <vika@fireburn.ru>2022-09-28 03:55:48 +0300
commit6e20a3c51756c2e84290da6ec53b89a5fc58c0fc (patch)
treea360c40dce27b7804001038babd4631476232001 /kittybox-rs/src/frontend/onboarding.rs
parent2f02bf76a40c971b9404aa0913bc8baa7dfde24c (diff)
downloadkittybox-6e20a3c51756c2e84290da6ec53b89a5fc58c0fc.tar.zst
Use tokens from the auth backend to authenticate for Micropub
Diffstat (limited to 'kittybox-rs/src/frontend/onboarding.rs')
-rw-r--r--kittybox-rs/src/frontend/onboarding.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/kittybox-rs/src/frontend/onboarding.rs b/kittybox-rs/src/frontend/onboarding.rs
index b498aed..b460e6a 100644
--- a/kittybox-rs/src/frontend/onboarding.rs
+++ b/kittybox-rs/src/frontend/onboarding.rs
@@ -54,8 +54,12 @@ async fn onboard<D: Storage + 'static>(
 ) -> Result<(), FrontendError> {
     // Create a user to pass to the backend
     // At this point the site belongs to nobody, so it is safe to do
-    let user =
-        crate::tokenauth::User::new(user_uid.as_str(), "https://kittybox.fireburn.ru/", "create");
+    let user = kittybox_indieauth::TokenData {
+        me: user_uid.clone(),
+        client_id: "https://kittybox.fireburn.ru/".parse().unwrap(),
+        scope: kittybox_indieauth::Scopes::new(vec![kittybox_indieauth::Scope::Create]),
+        iat: None, exp: None
+    };
 
     if data.user["type"][0] != "h-card" || data.first_post["type"][0] != "h-entry" {
         return Err(FrontendError::with_code(
@@ -96,7 +100,7 @@ async fn onboard<D: Storage + 'static>(
             .map_err(FrontendError::from)?;
     }
     let (uid, post) = crate::micropub::normalize_mf2(data.first_post, &user);
-    crate::micropub::_post(user, uid, post, db, http)
+    crate::micropub::_post(&user, uid, post, db, http)
         .await
         .map_err(|e| FrontendError {
             msg: "Error while posting the first post".to_string(),