Skip to content

Commit

Permalink
Remove old sign_in_with_email_and_password
Browse files Browse the repository at this point in the history
  • Loading branch information
Proziam committed Sep 29, 2024
1 parent 6efb253 commit f99c66a
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,12 @@ impl AuthClient {
/// # Example
/// ```
/// let session = auth_client
/// .sign_in_with_email_and_password(demo_email, demo_password)
/// .login_with_email(demo_email, demo_password)
/// .await
/// .unwrap();
///
/// assert!(session.user.email == demo_email)
/// ```
pub async fn sign_in_with_email_and_password<S: Into<String>>(
&self,
email: S,
password: S,
) -> Result<Session, Error> {
let payload = SignInWithEmailAndPasswordPayload {
email: email.into(),
password: password.into(),
};

let mut headers = header::HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers.insert("apikey", HeaderValue::from_str(&self.api_key)?);
let body = serde_json::to_string(&payload)?;

let response = self
.client
.post(format!(
"{}/auth/v1/token?grant_type=password",
self.project_url
))
.headers(headers)
.body(body)
.send()
.await?
.text()
.await?;

Ok(serde_json::from_str(&response)?)
}

pub async fn login_with_email<S: Into<String>>(
&self,
email: S,
Expand Down

0 comments on commit f99c66a

Please sign in to comment.