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

Add resetPasswordRedirectTo prop to Auth component #223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion packages/react/src/components/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Auth({
queryParams,
view = 'sign_in',
redirectTo,
resetPasswordRedirectTo,
onlyThirdPartyProviders = false,
magicLink = false,
showLinks = true,
Expand Down Expand Up @@ -176,7 +177,7 @@ function Auth({
appearance={appearance}
supabaseClient={supabaseClient}
setAuthView={setAuthView}
redirectTo={redirectTo}
redirectTo={resetPasswordRedirectTo ?? redirectTo}
Copy link

@alukach alukach Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be designed to specify the redirect URL based on the view state of the Auth component?

redirectTo={
  view === 'forgotten_password' 
    ? resetPasswordRedirectTo ?? redirectTo 
    : redirectTo
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I now see that this is already under the case VIEWS.FORGOTTEN_PASSWORD: condition, thus there's no need to check view... Disregard.

showLinks={showLinks}
i18n={i18n}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface BaseAuth {
queryParams?: { [key: string]: string }
view?: ViewType
redirectTo?: RedirectTo
resetPasswordRedirectTo?: RedirectTo
onlyThirdPartyProviders?: boolean
magicLink?: boolean
showLinks?: boolean
Expand Down
4 changes: 3 additions & 1 deletion packages/solid/src/components/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,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()}
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/svelte/src/lib/Auth/Auth.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,7 +122,7 @@
bind:authView={view}
{showLinks}
{appearance}
{redirectTo}
redirectTo={resetPasswordRedirectTo ?? redirectTo}
/>
{/if}
{#if view === VIEWS.MAGIC_LINK}
Expand Down