From 2b52d686d4fe2ccb3b779f2e167a09b4d6c37fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C5=9Eener?= Date: Mon, 18 Sep 2023 10:34:02 +0200 Subject: [PATCH] Add resetPasswordRedirectTo prop to Auth component This prop allows you to redirect users to a page where they can set their new password. Previously, it would behave as if the users just logged in. --- packages/react/src/components/Auth/Auth.tsx | 3 ++- packages/shared/src/types.ts | 1 + packages/solid/src/components/Auth/Auth.tsx | 4 +++- packages/svelte/src/lib/Auth/Auth.svelte | 10 +++++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/react/src/components/Auth/Auth.tsx b/packages/react/src/components/Auth/Auth.tsx index af9a2fe1..ac0122f2 100644 --- a/packages/react/src/components/Auth/Auth.tsx +++ b/packages/react/src/components/Auth/Auth.tsx @@ -21,6 +21,7 @@ function Auth({ queryParams, view = 'sign_in', redirectTo, + resetPasswordRedirectTo, onlyThirdPartyProviders = false, magicLink = false, showLinks = true, @@ -173,7 +174,7 @@ function Auth({ appearance={appearance} supabaseClient={supabaseClient} setAuthView={setAuthView} - redirectTo={redirectTo} + redirectTo={resetPasswordRedirectTo ?? redirectTo} showLinks={showLinks} i18n={i18n} /> diff --git a/packages/shared/src/types.ts b/packages/shared/src/types.ts index d578b6dd..26d1e121 100644 --- a/packages/shared/src/types.ts +++ b/packages/shared/src/types.ts @@ -89,6 +89,7 @@ export interface BaseAuth { queryParams?: { [key: string]: string } view?: ViewType redirectTo?: RedirectTo + resetPasswordRedirectTo?: RedirectTo onlyThirdPartyProviders?: boolean magicLink?: boolean showLinks?: boolean diff --git a/packages/solid/src/components/Auth/Auth.tsx b/packages/solid/src/components/Auth/Auth.tsx index d62835a7..066e76fa 100644 --- a/packages/solid/src/components/Auth/Auth.tsx +++ b/packages/solid/src/components/Auth/Auth.tsx @@ -259,7 +259,9 @@ function Auth(props: AuthProps): JSX.Element | null { appearance={mergedProps().appearance} supabaseClient={mergedProps().supabaseClient} setAuthView={setAuthView} - redirectTo={mergedProps().redirectTo} + redirectTo={ + mergedProps().resetPasswordRedirectTo ?? mergedProps().redirectTo + } showLinks={mergedProps().showLinks} i18n={i18n()} /> diff --git a/packages/svelte/src/lib/Auth/Auth.svelte b/packages/svelte/src/lib/Auth/Auth.svelte index 2e926a2e..073e20f3 100644 --- a/packages/svelte/src/lib/Auth/Auth.svelte +++ b/packages/svelte/src/lib/Auth/Auth.svelte @@ -27,6 +27,7 @@ export let queryParams: { [key: string]: string } | undefined = undefined; export let view: ViewType = 'sign_in'; export let redirectTo: string | undefined = undefined; + export let resetPasswordRedirectTo: string | undefined = undefined; export let onlyThirdPartyProviders = false; export let magicLink = false; export let showLinks = true; @@ -113,7 +114,14 @@ {/if} {/if} {#if view === VIEWS.FORGOTTEN_PASSWORD} - + {/if} {#if view === VIEWS.MAGIC_LINK}