about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-08-18 00:13:29 +0300
committerVika <vika@fireburn.ru>2024-08-18 00:19:30 +0300
commitf5587c32d42c8b0ce591affd2ef5d7a30c24257f (patch)
tree1ac9eb8b7598ec79198a00be0eb8125761e2eb2b
parent298c8c885350d7de581f927f1d196a797627bd9f (diff)
kittybox-indieauth: separate ProfileUrl struct from GrantResponse
Seems to be useful on its own.
-rw-r--r--indieauth/src/lib.rs18
-rw-r--r--src/indieauth/mod.rs2
2 files changed, 12 insertions, 8 deletions
diff --git a/indieauth/src/lib.rs b/indieauth/src/lib.rs
index ce0ef9f..cbe9085 100644
--- a/indieauth/src/lib.rs
+++ b/indieauth/src/lib.rs
@@ -585,13 +585,17 @@ pub enum GrantResponse {
     ///
     /// This is suitable for confirming the identity of the user, but
     /// no more than that.
-    ProfileUrl {
-        /// The authenticated user's URL.
-        me: Url,
-        /// The user's profile information, if it was requested.
-        #[serde(skip_serializing_if = "Option::is_none")]
-        profile: Option<Profile>
-    }
+    ProfileUrl(ProfileUrl)
+}
+
+/// The contents of a profile URL response.
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+pub struct ProfileUrl {
+    /// The authenticated user's URL.
+    pub me: Url,
+    /// The user's profile information, if it was requested.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub profile: Option<Profile>
 }
 
 #[cfg(feature = "axum")]
diff --git a/src/indieauth/mod.rs b/src/indieauth/mod.rs
index de4c367..c09b426 100644
--- a/src/indieauth/mod.rs
+++ b/src/indieauth/mod.rs
@@ -400,7 +400,7 @@ async fn authorization_endpoint_post<A: AuthBackend, D: Storage + 'static>(
                 None
             };
 
-            GrantResponse::ProfileUrl { me, profile }.into_response()
+            GrantResponse::ProfileUrl(ProfileUrl { me, profile }).into_response()
         },
         _ => Error {
             kind: ErrorKind::InvalidGrant,