From 32f52945de109e829f7cc39fdf44b9f63d736df4 Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Sat, 1 Feb 2025 10:03:49 +0800 Subject: [PATCH] refactor(auth): update sign-in and sign-up pages to use server-side authentication --- src/app/(auth)/sign-in/page.tsx | 10 +++++++--- src/app/(auth)/sign-up/page.tsx | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/(auth)/sign-in/page.tsx b/src/app/(auth)/sign-in/page.tsx index a02c5b7..c77e7f9 100644 --- a/src/app/(auth)/sign-in/page.tsx +++ b/src/app/(auth)/sign-in/page.tsx @@ -1,8 +1,12 @@ -"use client"; - +import { redirect } from "next/navigation"; +import { getCurrent } from "@/features/auth/actions"; import { SignInCard } from "@/features/auth/components/sign-in-card"; -const SignInPage = () => { +const SignInPage = async () => { + const user = await getCurrent(); + + if (user) redirect("/"); + return ; }; diff --git a/src/app/(auth)/sign-up/page.tsx b/src/app/(auth)/sign-up/page.tsx index 00c76fb..1c5aa16 100644 --- a/src/app/(auth)/sign-up/page.tsx +++ b/src/app/(auth)/sign-up/page.tsx @@ -1,8 +1,12 @@ -"use client"; - +import { redirect } from "next/navigation"; +import { getCurrent } from "@/features/auth/actions"; import { SignUpCard } from "@/features/auth/components/sign-up-card"; -const SignUpPage = () => { +const SignUpPage = async () => { + const user = await getCurrent(); + + if (user) redirect("/"); + return ; };