summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/signin.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/components/signin.rs b/src/components/signin.rs
index c595bde..08e850a 100644
--- a/src/components/signin.rs
+++ b/src/components/signin.rs
@@ -12,6 +12,7 @@ pub struct Output {
     pub me: glib::Uri,
     pub micropub: glib::Uri,
     pub userinfo: Option<glib::Uri>,
+    pub scope: kittybox_indieauth::Scopes,
 
     pub access_token: String,
     pub refresh_token: Option<String>,
@@ -123,6 +124,14 @@ fn callback_handler(sender: AsyncComponentSender<SignIn>) -> impl Fn(&soup::Serv
 }
 
 impl SignIn {
+    fn scopes() -> kittybox_indieauth::Scopes {
+        kittybox_indieauth::Scopes::new(vec![
+            kittybox_indieauth::Scope::Profile,
+            kittybox_indieauth::Scope::Create,
+            kittybox_indieauth::Scope::Media
+        ])
+    }
+
     fn bail_out(&mut self, widgets: &mut <Self as AsyncComponent>::Widgets, sender: AsyncComponentSender<Self>, err: Error) {
         widgets.toasts.add_toast(adw::Toast::builder()
             .title(err.to_string())
@@ -401,11 +410,7 @@ impl AsyncComponent for SignIn {
                     code_challenge: kittybox_indieauth::PKCEChallenge::new(
                         &self.code_verifier, kittybox_indieauth::PKCEMethod::S256
                     ),
-                    scope: Some(kittybox_indieauth::Scopes::new(vec![
-                        kittybox_indieauth::Scope::Profile,
-                        kittybox_indieauth::Scope::Create,
-                        kittybox_indieauth::Scope::Media
-                    ])),
+                    scope: Some(Self::scopes()),
                     me: Some(url.to_str().parse().unwrap())
                 };
 
@@ -496,6 +501,7 @@ impl AsyncComponent for SignIn {
                             }) => {
                                 let _ = sender.output(Output {
                                     me: glib::Uri::parse(me.as_str(), glib::UriFlags::NONE).unwrap(),
+                                    scope: scope.unwrap_or_else(Self::scopes),
                                     micropub: micropub_uri,
                                     userinfo: metadata.userinfo_endpoint
                                         .map(|u| glib::Uri::parse(