feat:(SW-360): redirect authenticated users away from signup

This commit is contained in:
Chuma McPhoy
2024-10-03 14:16:08 +02:00
committed by Pontus Dreij
parent 3407d48f6a
commit 65b61c900b
4 changed files with 25 additions and 181 deletions
@@ -0,0 +1,23 @@
import { redirect } from "next/navigation"
import { overview } from "@/constants/routes/myPages"
import { auth } from "@/auth"
import { getLang } from "@/i18n/serverContext"
import Form from "../index"
import { RegisterFormProps } from "@/types/components/form/registerForm"
export default async function ServerRegisterForm({
link,
subtitle,
title,
}: RegisterFormProps) {
const session = await auth()
if (session) {
// We don't want to allow users to signup if they are already authenticated.
redirect(overview[getLang()])
}
return <Form link={link} subtitle={subtitle} title={title} />
}