Use signWithOtp method instead of the resend endpoint

close #1385
This commit is contained in:
edouardparis 2024-10-23 12:53:43 +02:00
parent 2711e34430
commit e3ae1f369b

View File

@ -116,22 +116,13 @@ impl AuthClient {
Ok(())
}
pub async fn resend_otp(&self) -> Result<Response, AuthError> {
let response: Response = self
.request(Method::POST, &format!("{}/auth/v1/resend", self.url))
.json(&ResendOtp {
email: &self.email,
kind: "signup",
})
.send()
.await?;
if !response.status().is_success() {
return Err(AuthError {
http_status: Some(response.status().into()),
error: response.text().await?,
});
}
Ok(response)
/// Resend method has to trigger a signInWithOTP method instead of using the resend endpoint.
/// The resend endpoint is used to resend an existing signup confirmation email, email change email, SMS OTP phone signup)
/// or phone change OTP. This method will only resend an email or phone OTP to the user if there was an initial signup,
/// email change or phone change request being made.
/// If we want to resend a passwordless sign-in OTP or Magic Link, we have to use the signInWithOtp() method again.
pub async fn resend_otp(&self) -> Result<(), AuthError> {
self.sign_in_otp().await
}
pub async fn verify_otp(&self, token: &str) -> Result<AccessTokenResponse, AuthError> {