use serde_json::json;
use crate::error::Result;
use crate::universals::{HttpMethod, RequestOptions};
use crate::SupabaseClient;
impl SupabaseClient {
#[deprecated(
since = "0.5.0",
note = "use `client.auth().reset_password_for_email(email, ResetPasswordOptions::default())`"
)]
pub async fn forgot_password(&self, email: &str) -> Result<()> {
self.request_with(
"/auth/v1/recover",
HttpMethod::Post,
Some(json!({ "email": email })),
&RequestOptions::auth(),
)
.await?;
Ok(())
}
#[deprecated(
since = "0.5.0",
note = "use `client.auth().verify_otp(...)` then `client.auth().update_user(...)`"
)]
pub async fn reset_password(
&self,
new_password: &str,
access_token: &str,
otp: &str,
) -> Result<()> {
let opts = RequestOptions {
bearer_override: Some(access_token.to_string()),
..RequestOptions::auth()
};
self.request_with(
"/auth/v1/user",
HttpMethod::Put,
Some(json!({ "password": new_password, "code": otp })),
&opts,
)
.await?;
Ok(())
}
}