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

fix: 29 Prevent access to sign-in pages when logged in #144

Open
wants to merge 1 commit 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
10 changes: 9 additions & 1 deletion src/app/(auth)/signin/[[...signin]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ import {
import { Shell } from "@/components/shell"
import { OAuthSignIn } from "@/app/(auth)/_components/oauth-signin"
import { SignInForm } from "@/app/(auth)/_components/signin-form"
import { redirect } from "next/navigation";
import { getCachedUser } from "@/lib/queries/user";

export const metadata: Metadata = {
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
title: "Sign In",
description: "Sign in to your account",
}

export default function SignInPage() {
export default async function SignInPage() {
const user = await getCachedUser();

if (user) {
redirect("/");
}

return (
<Shell className="max-w-lg">
<Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ import {
} from "@/components/ui/card"
import { Shell } from "@/components/shell"
import { ResetPasswordForm } from "@/app/(auth)/_components/reset-password-form"
import { redirect } from "next/navigation";
import { getCachedUser } from "@/lib/queries/user";

export const metadata: Metadata = {
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
title: "Reset Password",
description: "Enter your email to reset your password",
}

export default function ResetPasswordPage() {
export default async function ResetPasswordPage() {
const user = await getCachedUser();

if (user) {
redirect("/");
}

return (
<Shell className="max-w-lg">
<Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ import {
} from "@/components/ui/card"
import { Shell } from "@/components/shell"
import { ResetPasswordConfirmForm } from "@/app/(auth)/_components/reset-password-confirm-form"
import { redirect } from "next/navigation";
import { getCachedUser } from "@/lib/queries/user";

export const metadata: Metadata = {
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
title: "Reset Password",
description: "Enter your email to reset your password",
}

export default function ResetPasswordConfirmPage() {
export default async function ResetPasswordConfirmPage() {
const user = await getCachedUser();

if (user) {
redirect("/");
}

return (
<Shell className="max-w-lg">
<Card>
Expand Down
10 changes: 9 additions & 1 deletion src/app/(auth)/signup/[[...signup]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ import {
import { Shell } from "@/components/shell"
import { OAuthSignIn } from "@/app/(auth)/_components/oauth-signin"
import { SignUpForm } from "@/app/(auth)/_components/signup-form"
import { redirect } from "next/navigation";
import { getCachedUser } from "@/lib/queries/user";

export const metadata: Metadata = {
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
title: "Sign Up",
description: "Sign up for an account",
}

export default function SignUpPage() {
export default async function SignUpPage() {
const user = await getCachedUser();

if (user) {
redirect("/");
}

return (
<Shell className="max-w-lg">
<Card>
Expand Down
10 changes: 9 additions & 1 deletion src/app/(auth)/signup/verify-email/[[...verify-email]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ import {
} from "@/components/ui/card"
import { Shell } from "@/components/shell"
import { VerifyEmailForm } from "@/app/(auth)/_components/verify-email-form"
import { redirect } from "next/navigation";
import { getCachedUser } from "@/lib/queries/user";

export const metadata: Metadata = {
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
title: "Verify Email",
description: "Verify your email address to continue with your sign up",
}

export default function VerifyEmailPage() {
export default async function VerifyEmailPage() {
const user = await getCachedUser();

if (user) {
redirect("/");
}

return (
<Shell className="max-w-lg">
<Card>
Expand Down
10 changes: 9 additions & 1 deletion src/app/(auth)/sso-callback/[[...sso-callback]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ import { AuthenticateWithRedirectCallback } from "@clerk/nextjs"

import { Icons } from "@/components/icons"
import { Shell } from "@/components/shell"
import { redirect } from "next/navigation";
import { getCachedUser } from "@/lib/queries/user";

export default function SSOCallbackPage() {
export default async function SSOCallbackPage() {
const user = await getCachedUser();

if (user) {
redirect("/");
}

return (
<Shell className="max-w-lg place-items-center">
<Icons.spinner className="size-16 animate-spin" aria-hidden="true" />
Expand Down