mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 19:21:39 +10:00
fix: preserve params when you are not signed in
This commit is contained in:
@ -20,6 +20,8 @@ export function meta() {
|
|||||||
|
|
||||||
export async function loader({ request }: Route.LoaderArgs) {
|
export async function loader({ request }: Route.LoaderArgs) {
|
||||||
const { isAuthenticated } = await getOptionalSession(request);
|
const { isAuthenticated } = await getOptionalSession(request);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const redirectParam = url.searchParams.get('redirect');
|
||||||
|
|
||||||
// SSR env variables.
|
// SSR env variables.
|
||||||
const isGoogleSSOEnabled = IS_GOOGLE_SSO_ENABLED;
|
const isGoogleSSOEnabled = IS_GOOGLE_SSO_ENABLED;
|
||||||
@ -27,6 +29,9 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||||||
const oidcProviderLabel = OIDC_PROVIDER_LABEL;
|
const oidcProviderLabel = OIDC_PROVIDER_LABEL;
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
|
if (redirectParam) {
|
||||||
|
throw redirect(redirectParam);
|
||||||
|
}
|
||||||
throw redirect('/');
|
throw redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,11 +39,12 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||||||
isGoogleSSOEnabled,
|
isGoogleSSOEnabled,
|
||||||
isOIDCSSOEnabled,
|
isOIDCSSOEnabled,
|
||||||
oidcProviderLabel,
|
oidcProviderLabel,
|
||||||
|
redirectTo: redirectParam,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SignIn({ loaderData }: Route.ComponentProps) {
|
export default function SignIn({ loaderData }: Route.ComponentProps) {
|
||||||
const { isGoogleSSOEnabled, isOIDCSSOEnabled, oidcProviderLabel } = loaderData;
|
const { isGoogleSSOEnabled, isOIDCSSOEnabled, oidcProviderLabel, redirectTo } = loaderData;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-screen max-w-lg px-4">
|
<div className="w-screen max-w-lg px-4">
|
||||||
@ -56,6 +62,7 @@ export default function SignIn({ loaderData }: Route.ComponentProps) {
|
|||||||
isGoogleSSOEnabled={isGoogleSSOEnabled}
|
isGoogleSSOEnabled={isGoogleSSOEnabled}
|
||||||
isOIDCSSOEnabled={isOIDCSSOEnabled}
|
isOIDCSSOEnabled={isOIDCSSOEnabled}
|
||||||
oidcProviderLabel={oidcProviderLabel}
|
oidcProviderLabel={oidcProviderLabel}
|
||||||
|
returnTo={redirectTo || undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{env('NEXT_PUBLIC_DISABLE_SIGNUP') !== 'true' && (
|
{env('NEXT_PUBLIC_DISABLE_SIGNUP') !== 'true' && (
|
||||||
|
|||||||
@ -9,7 +9,9 @@ import type { Route } from './+types/billing-redirect';
|
|||||||
export async function loader({ request }: Route.LoaderArgs) {
|
export async function loader({ request }: Route.LoaderArgs) {
|
||||||
const session = await getOptionalSession(request);
|
const session = await getOptionalSession(request);
|
||||||
if (!session.isAuthenticated) {
|
if (!session.isAuthenticated) {
|
||||||
throw redirect('/signin');
|
const currentUrl = new URL(request.url);
|
||||||
|
const redirectParam = encodeURIComponent(currentUrl.pathname + currentUrl.search);
|
||||||
|
throw redirect(`/signin?redirect=${redirectParam}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
|
|||||||
Reference in New Issue
Block a user