fix(SW-890): more reliable checking of user

This commit is contained in:
Chuma McPhoy
2024-11-15 12:57:32 +01:00
parent 5fef56cc97
commit d65be1845a
2 changed files with 6 additions and 6 deletions

View File

@@ -1,8 +1,8 @@
import { redirect } from "next/navigation"
import { overview } from "@/constants/routes/myPages"
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
import { auth } from "@/auth"
import SignupForm from "@/components/Forms/Signup"
import { getLang } from "@/i18n/serverContext"
@@ -11,8 +11,8 @@ import { SignupFormWrapperProps } from "@/types/components/blocks/dynamicContent
export default async function SignupFormWrapper({
dynamic_content,
}: SignupFormWrapperProps) {
const session = await auth()
if (session) {
const user = await getProfileSafely()
if (user) {
// We don't want to allow users to access signup if they are already authenticated.
redirect(overview[getLang()])
}