From 6e20a3c51756c2e84290da6ec53b89a5fc58c0fc Mon Sep 17 00:00:00 2001 From: Vika Date: Wed, 28 Sep 2022 03:55:48 +0300 Subject: Use tokens from the auth backend to authenticate for Micropub --- kittybox-rs/src/frontend/onboarding.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'kittybox-rs/src/frontend/onboarding.rs') 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( ) -> 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( .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(), -- cgit 1.4.1