Skip to content

Commit

Permalink
feat: Allow password recovery email to be redirected to other URL (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
dshukertjr authored Jun 20, 2024
1 parent 72a861f commit 9fe1fd2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/components/supa_email_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -93,6 +99,7 @@ class SupaEmailAuth extends StatefulWidget {
const SupaEmailAuth({
super.key,
this.redirectTo,
this.resetPasswordRedirectTo,
required this.onSignInComplete,
required this.onSignUpComplete,
this.onPasswordResetEmailSent,
Expand Down Expand Up @@ -308,7 +315,8 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
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
Expand Down

0 comments on commit 9fe1fd2

Please sign in to comment.