about summary refs log tree commit diff
path: root/templates/src/indieauth.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-08-18 00:30:15 +0300
committerVika <vika@fireburn.ru>2024-08-18 00:30:15 +0300
commite43313210269b8e48fe35b17ac416c9ba88ae4f3 (patch)
tree51941c5149351bb32260fb8cbd4293eed80563e0 /templates/src/indieauth.rs
parentcd8029a930b966225d0a57afb1ee29808fe2a409 (diff)
feat: logins!!
yes you can finally sign in

this is also supposed to show private posts intended for you!

maybe i can also reveal my email to those who sign in! :3
Diffstat (limited to 'templates/src/indieauth.rs')
-rw-r--r--templates/src/indieauth.rs31
1 files changed, 9 insertions, 22 deletions
diff --git a/templates/src/indieauth.rs b/templates/src/indieauth.rs
index 155b580..5f92196 100644
--- a/templates/src/indieauth.rs
+++ b/templates/src/indieauth.rs
@@ -1,11 +1,13 @@
-use kittybox_indieauth::{AuthorizationRequest, Scope};
+use kittybox_indieauth::{AuthorizationRequest, ClientMetadata, Scope};
 use kittybox_util::auth::EnrolledCredential;
 
+const INDIEAUTH_SPEC: &str = "https://indieauth.spec.indieweb.org/20240711/#authorization-request";
+
 markup::define! {
     AuthorizationRequestPage(
         request: AuthorizationRequest,
         credentials: Vec<EnrolledCredential>,
-        app: Option<serde_json::Value>,
+        app: ClientMetadata,
         user: serde_json::Value
     ) {
         script[type="module"] {
@@ -37,27 +39,12 @@ document.getElementById("indieauth_page").addEventListener("submit", submit_hand
                     }
 
                     p."mini-h-card" {
-                        @if let Some(icon) = app
-                            .as_ref()
-                            .and_then(|app| app["properties"]["logo"][0].as_str())
-                        {
-                            img.app_icon[src=icon];
-                        } else if let Some(icon) = app
-                            .as_ref()
-                            .and_then(|app| app["properties"]["logo"][0].as_object())
-                        {
-                            img.app_icon[src=icon["src"].as_str().unwrap(), alt=icon["alt"].as_str().unwrap()];
+                        @if let Some(icon) = app.logo_uri.as_ref() {
+                            img.app_icon[src=icon.as_str()];
                         }
                         span {
-                            a[href=app
-                              .as_ref()
-                              .and_then(|app| app["properties"]["url"][0].as_str())
-                              .unwrap_or_else(|| request.client_id.as_str())
-                            ] {
-                                @app
-                                    .as_ref()
-                                    .and_then(|app| app["properties"]["name"][0].as_str())
-                                    .unwrap_or_else(|| request.client_id.as_str())
+                            a[href=app.client_uri.as_str()] {
+                                @app.client_name.as_deref().unwrap_or_else(|| request.client_id.as_str())
                             }
                             " wants to confirm your identity."
                         }
@@ -152,7 +139,7 @@ document.getElementById("indieauth_page").addEventListener("submit", submit_hand
 
                     p {
                         "More info about meanings of these fields can be found in "
-                            a[href="https://indieauth.spec.indieweb.org/20220212/#authorization-request"] {
+                            a[href=INDIEAUTH_SPEC] {
                                 "the IndieAuth specification"
                             } ", which this webpage uses."
                     }