From 9fe1fd23b561fb0afd5dccc04e0ef1faed5d21cc Mon Sep 17 00:00:00 2001 From: Tyler Date: Thu, 20 Jun 2024 10:30:55 +0900 Subject: [PATCH] feat: Allow password recovery email to be redirected to other URL (#98) --- lib/src/components/supa_email_auth.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/components/supa_email_auth.dart b/lib/src/components/supa_email_auth.dart index c0d2acd..8c2d6be 100644 --- a/lib/src/components/supa_email_auth.dart +++ b/lib/src/components/supa_email_auth.dart @@ -57,6 +57,12 @@ class SupaEmailAuth extends StatefulWidget { /// confirmation link after signing up. final String? redirectTo; + /// The URL to redirect the user to when clicking on the link on the + /// password recovery link. + /// + /// If unspecified, the [redirectTo] value will be used. + final String? resetPasswordRedirectTo; + /// Callback for the user to complete a sign in. final void Function(AuthResponse response) onSignInComplete; @@ -93,6 +99,7 @@ class SupaEmailAuth extends StatefulWidget { const SupaEmailAuth({ super.key, this.redirectTo, + this.resetPasswordRedirectTo, required this.onSignInComplete, required this.onSignUpComplete, this.onPasswordResetEmailSent, @@ -308,7 +315,8 @@ class _SupaEmailAuthState extends State { final email = _emailController.text.trim(); await supabase.auth.resetPasswordForEmail( email, - redirectTo: widget.redirectTo, + redirectTo: + widget.resetPasswordRedirectTo ?? widget.redirectTo, ); widget.onPasswordResetEmailSent?.call(); // FIX use_build_context_synchronously