From a276c5b08d30bafbfcd997ca6250eb701da7fa3c Mon Sep 17 00:00:00 2001 From: Eric Biggs Date: Sun, 27 Oct 2024 14:10:16 -0400 Subject: [PATCH] Added test for anonymous sign in --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- src/client.rs | 2 ++ src/models.rs | 6 ++++-- tests/client_tests.rs | 11 +++++++++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd4947e..edd8f49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -677,9 +677,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ "bitflags", "errno", @@ -869,7 +869,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "supabase-auth" -version = "0.10.1" +version = "0.10.2" dependencies = [ "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 46fe461..fd37b57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "supabase-auth" authors = ["Eric Biggs"] description = "Supabase Auth implementation following the official client libraries." readme = "README.md" -version = "0.10.1" +version = "0.10.2" edition = "2021" license = "MIT OR Apache-2.0" keywords = ["supabase", "supabase-auth", "authentication", "auth"] diff --git a/src/client.rs b/src/client.rs index 9e3077b..94e825b 100644 --- a/src/client.rs +++ b/src/client.rs @@ -242,6 +242,8 @@ impl AuthClient { /// named like this here. You can also pass in the same signup options /// that work for the other `sign_up_*` methods, but that's not required. /// + /// This method requires anonymous sign in to be enabled in your dashboard. + /// /// # Example /// ``` /// let session = auth_client diff --git a/src/models.rs b/src/models.rs index a8fc089..c39d195 100644 --- a/src/models.rs +++ b/src/models.rs @@ -70,8 +70,10 @@ pub struct User { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Default)] pub struct AppMetadata { - pub provider: String, - pub providers: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub provider: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub providers: Option>, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Default)] diff --git a/tests/client_tests.rs b/tests/client_tests.rs index 7007c75..b1a020f 100644 --- a/tests/client_tests.rs +++ b/tests/client_tests.rs @@ -413,6 +413,17 @@ async fn invite_by_email_test() { assert!(user.email == demo_email) } +#[tokio::test] +async fn sign_in_anonymously_test() { + let auth_client = create_test_client(); + + let session = auth_client.sign_in_anonymously(None).await.unwrap(); + + println!("{}", session.user.created_at); + + assert!(!session.access_token.is_empty() && session.user.role == "authenticated") +} + #[tokio::test] async fn get_settings_test() { let auth_client = create_test_client();