Skip to content

Commit

Permalink
hunting down a bug related to serde
Browse files Browse the repository at this point in the history
It's a skill issue
  • Loading branch information
Eric Biggs committed Sep 15, 2024
1 parent 661df6e commit e9ad4dd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "supabase-auth"
authors = ["Eric Biggs"]
description = "Supabase Auth implementation following the official client libraries."
readme = "README.md"
version = "0.1.5"
version = "0.1.6"
edition = "2021"
license = "MIT OR Apache-2.0"
keywords = ["supabase", "supabase-auth", "authentication", "auth"]
Expand Down
19 changes: 11 additions & 8 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use crate::{
Provider, RequestMagicLinkPayload, Session, SignInEmailOtpParams,
SignInWithEmailAndPasswordPayload, SignInWithEmailOtpPayload, SignInWithIdTokenCredentials,
SignInWithPhoneAndPasswordPayload, SignUpWithEmailAndPasswordPayload,
SignUpWithPhoneAndPasswordPayload, UpdateUserPayload, User, VerifyOtpParams,
SignUpWithPhoneAndPasswordPayload, UpdateUserPayload, User, VerifyEmailOtpParams,
VerifyMobileOtpParams, VerifyOtpParams, VerifyTokenHashParams,
},
};

Expand Down Expand Up @@ -403,15 +404,17 @@ impl AuthClient {
let mut headers = HeaderMap::new();
headers.insert("apikey", self.api_key.parse()?);
headers.insert(CONTENT_TYPE, "application/json".parse()?);
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("Bearer {}", &self.api_key))?,
);

let body = match params {
VerifyOtpParams::Mobile(params) => serde_json::to_string(&params)?,
VerifyOtpParams::Email(params) => serde_json::to_string(&params)?,
VerifyOtpParams::TokenHash(params) => serde_json::to_string(&params)?,
VerifyOtpParams::Mobile(params) => {
serde_json::to_string::<VerifyMobileOtpParams>(&params)?
}
VerifyOtpParams::Email(params) => {
serde_json::to_string::<VerifyEmailOtpParams>(&params)?
}
VerifyOtpParams::TokenHash(params) => {
serde_json::to_string::<VerifyTokenHashParams>(&params)?
}
};

let client = Client::new();
Expand Down
1 change: 1 addition & 0 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ pub struct SignInMobileOtpParams {
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Channel {
Sms,
Whatsapp,
Expand Down
5 changes: 4 additions & 1 deletion tests/client_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::env;

use reqwest::header;
use supabase_auth::client::AuthClient;
use supabase_auth::{
client::AuthClient,
models::{VerifyEmailOtpParams, VerifyOtpParams},
};

#[tokio::test]
async fn create_client_test_valid() {
Expand Down

0 comments on commit e9ad4dd

Please sign in to comment.