Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow password recovery email to be redirected to other URL #98

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -87,6 +93,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 @@ -295,7 +302,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
Loading