Skip to content

Commit 0724c25

Browse files
feat: Configure the sign in page redirect from constants
1 parent 10c5f06 commit 0724c25

File tree

10 files changed

+22
-14
lines changed

10 files changed

+22
-14
lines changed

src/app/(auth)/sign-in/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Metadata } from "next";
22
import { getSessionFromCookie } from "@/utils/auth";
33
import { redirect } from "next/navigation";
44
import SignInClientPage from "./sign-in.client";
5-
5+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
66
export const metadata: Metadata = {
77
title: "Sign In",
88
description: "Sign in to your account",
@@ -12,7 +12,7 @@ const SignInPage = async () => {
1212
const session = await getSessionFromCookie();
1313

1414
if (session) {
15-
return redirect('/dashboard');
15+
return redirect(REDIRECT_AFTER_SIGN_IN);
1616
}
1717

1818
return (

src/app/(auth)/sign-in/sign-in.client.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import SSOButtons from "../_components/sso-buttons";
1818
import { KeyIcon } from "lucide-react";
1919
import { generateAuthenticationOptionsAction, verifyAuthenticationAction } from "@/app/(settings)/settings/security/passkey-settings.actions";
2020
import { startAuthentication } from "@simplewebauthn/browser";
21+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
2122

2223
interface PasskeyAuthenticationButtonProps {
2324
className?: string;
@@ -41,7 +42,7 @@ function PasskeyAuthenticationButton({ className, disabled, children }: PasskeyA
4142
onSuccess: () => {
4243
toast.dismiss();
4344
toast.success("Authentication successful");
44-
window.location.href = "/dashboard";
45+
window.location.href = REDIRECT_AFTER_SIGN_IN;
4546
},
4647
});
4748

src/app/(auth)/sign-up/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Metadata } from "next";
22
import { getSessionFromCookie } from "@/utils/auth";
33
import SignUpClientComponent from "./sign-up.client";
44
import { redirect } from "next/navigation";
5-
5+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
66
export const metadata: Metadata = {
77
title: "Sign Up",
88
description: "Create a new account",
@@ -12,7 +12,7 @@ const SignUpPage = async () => {
1212
const session = await getSessionFromCookie();
1313

1414
if (session) {
15-
return redirect('/dashboard');
15+
return redirect(REDIRECT_AFTER_SIGN_IN);
1616
}
1717

1818
return <SignUpClientComponent />

src/app/(auth)/sign-up/sign-up.client.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { useState } from "react";
2424
import { startRegistration } from "@simplewebauthn/browser";
2525
import { KeyIcon } from 'lucide-react'
2626
import { useConfigStore } from "@/state/config";
27-
27+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
2828
const SignUpPage = () => {
2929
const router = useRouter();
3030
const { isTurnstileEnabled } = useConfigStore();
@@ -42,7 +42,7 @@ const SignUpPage = () => {
4242
onSuccess: () => {
4343
toast.dismiss()
4444
toast.success("Account created successfully")
45-
router.push("/dashboard")
45+
router.push(REDIRECT_AFTER_SIGN_IN)
4646
}
4747
})
4848

@@ -55,7 +55,7 @@ const SignUpPage = () => {
5555
onSuccess: () => {
5656
toast.dismiss()
5757
toast.success("Account created successfully")
58-
router.push("/dashboard")
58+
router.push(REDIRECT_AFTER_SIGN_IN)
5959
}
6060
})
6161

src/app/(auth)/sso/google/callback/google-callback.client.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useServerAction } from "zsa-react";
99
import { googleSSOCallbackAction } from "./google-callback.action";
1010
import { googleSSOCallbackSchema } from "@/schemas/google-sso-callback.schema";
1111
import { Spinner } from "@/components/ui/spinner";
12+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
1213

1314
export default function GoogleCallbackClientComponent() {
1415
const router = useRouter();
@@ -28,7 +29,7 @@ export default function GoogleCallbackClientComponent() {
2829
onSuccess: () => {
2930
toast.dismiss();
3031
toast.success("Signed in successfully");
31-
window.location.href = "/dashboard";
32+
window.location.href = REDIRECT_AFTER_SIGN_IN;
3233
},
3334
});
3435

src/app/(auth)/sso/google/callback/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Metadata } from "next";
22
import { getSessionFromCookie } from "@/utils/auth";
33
import { redirect } from "next/navigation";
44
import GoogleCallbackClientComponent from "./google-callback.client";
5+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
56

67
export const metadata: Metadata = {
78
title: "Sign in with Google",
@@ -12,7 +13,7 @@ export default async function GoogleCallbackPage() {
1213
const session = await getSessionFromCookie();
1314

1415
if (session) {
15-
return redirect('/dashboard');
16+
return redirect(REDIRECT_AFTER_SIGN_IN);
1617
}
1718

1819
return <GoogleCallbackClientComponent />;

src/app/(auth)/sso/google/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import isProd from "@/utils/is-prod";
1212
import ms from "ms";
1313
import type { ResponseCookie } from "next/dist/compiled/@edge-runtime/cookies";
1414
import { isGoogleSSOEnabled } from "@/flags";
15-
15+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
1616
const cookieOptions: Partial<ResponseCookie> = {
1717
path: "/",
1818
httpOnly: true,
@@ -31,7 +31,7 @@ export async function GET() {
3131
const session = await getSessionFromCookie()
3232

3333
if (session) {
34-
return redirect('/dashboard')
34+
return redirect(REDIRECT_AFTER_SIGN_IN)
3535
}
3636

3737
let ssoRedirectUrl: null | URL = null

src/app/(auth)/verify-email/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Metadata } from "next";
22
import { getSessionFromCookie } from "@/utils/auth";
33
import { redirect } from "next/navigation";
44
import VerifyEmailClientComponent from "./verify-email.client";
5+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
56

67
export const metadata: Metadata = {
78
title: "Verify Email",
@@ -17,7 +18,7 @@ export default async function VerifyEmailPage({
1718
const token = (await searchParams).token;
1819

1920
if (session?.user.emailVerified) {
20-
return redirect('/dashboard');
21+
return redirect(REDIRECT_AFTER_SIGN_IN);
2122
}
2223

2324
if (!token) {

src/app/(auth)/verify-email/verify-email.client.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useServerAction } from "zsa-react";
99
import { verifyEmailAction } from "./verify-email.action";
1010
import { verifyEmailSchema } from "@/schemas/verify-email.schema";
1111
import { Spinner } from "@/components/ui/spinner";
12+
import { REDIRECT_AFTER_SIGN_IN } from "@/constants";
1213

1314
export default function VerifyEmailClientComponent() {
1415
const router = useRouter();
@@ -31,7 +32,7 @@ export default function VerifyEmailClientComponent() {
3132
router.refresh();
3233

3334
setTimeout(() => {
34-
router.push("/dashboard");
35+
router.push(REDIRECT_AFTER_SIGN_IN);
3536
}, 500);
3637
},
3738
});

src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Route } from "next"
2+
13
export const SITE_NAME = "SaaS Template"
24
export const SITE_DESCRIPTION = "A modern SaaS template built with Next.js 15 and Cloudflare Workers, designed for scalability and performance."
35
export const SITE_URL = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://saas-stack.startupstudio.dev"
@@ -20,3 +22,4 @@ export const CREDITS_EXPIRATION_YEARS = 2;
2022

2123
export const FREE_MONTHLY_CREDITS = CREDIT_PACKAGES[0].credits * 0.1;
2224
export const MAX_TRANSACTIONS_PER_PAGE = 10;
25+
export const REDIRECT_AFTER_SIGN_IN = "/dashboard" as Route;

0 commit comments

Comments
 (0)