@@ -32,7 +32,7 @@ use crate::{
32
32
LoginWithEmailAndPasswordPayload , LoginWithEmailOtpPayload , LoginWithOAuthOptions ,
33
33
LoginWithPhoneAndPasswordPayload , LoginWithSSO , LogoutScope , OAuthResponse , OTPResponse ,
34
34
Provider , RefreshSessionPayload , RequestMagicLinkPayload , ResendParams ,
35
- ResetPasswordForEmailPayload , SendSMSOtpPayload , Session ,
35
+ ResetPasswordForEmailPayload , ResetPasswordOptions , SendSMSOtpPayload , Session ,
36
36
SignUpWithEmailAndPasswordPayload , SignUpWithPasswordOptions ,
37
37
SignUpWithPhoneAndPasswordPayload , UpdatedUser , User , VerifyOtpParams , AUTH_V1 ,
38
38
} ,
@@ -1021,20 +1021,32 @@ impl AuthClient {
1021
1021
/// Valid email addresses that are not registered as users will not return an error.
1022
1022
/// # Example
1023
1023
/// ```
1024
- /// let response = auth_client.reset_password_for_email(demo_email).await.unwrap();
1024
+ /// let response = auth_client.reset_password_for_email(demo_email, None ).await.unwrap();
1025
1025
/// ```
1026
- pub async fn reset_password_for_email ( & self , email : & str ) -> Result < ( ) , Error > {
1026
+ pub async fn reset_password_for_email (
1027
+ & self ,
1028
+ email : & str ,
1029
+ options : Option < ResetPasswordOptions > ,
1030
+ ) -> Result < ( ) , Error > {
1031
+ let redirect_to = options
1032
+ . as_ref ( )
1033
+ . and_then ( |o| o. email_redirect_to . as_deref ( ) . map ( str:: to_owned) ) ;
1034
+
1035
+ let payload = ResetPasswordForEmailPayload {
1036
+ email : String :: from ( email) ,
1037
+ options,
1038
+ } ;
1039
+
1027
1040
let mut headers = HeaderMap :: new ( ) ;
1028
1041
headers. insert ( "apikey" , HeaderValue :: from_str ( & self . api_key ) ?) ;
1029
1042
headers. insert ( CONTENT_TYPE , HeaderValue :: from_str ( "application/json" ) ?) ;
1030
1043
1031
- let body = serde_json:: to_string ( & ResetPasswordForEmailPayload {
1032
- email : email. into ( ) ,
1033
- } ) ?;
1044
+ let body = serde_json:: to_string ( & payload) ?;
1034
1045
1035
1046
let response = self
1036
1047
. client
1037
1048
. post ( & format ! ( "{}{}/recover" , self . project_url, AUTH_V1 ) )
1049
+ . query ( & [ ( "redirect_to" , redirect_to. as_deref ( ) ) ] )
1038
1050
. headers ( headers)
1039
1051
. body ( body)
1040
1052
. send ( )
0 commit comments