feat/valid-session: check valid user/session from token instead of making a slow request to api
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { overview } from "@/constants/routes/myPages"
|
||||
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
import LoginButton from "@/components/LoginButton"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
import { isValidSession } from "@/utils/session"
|
||||
|
||||
import styles from "./signUpVerification.module.css"
|
||||
|
||||
@@ -14,8 +15,8 @@ import type { SignUpVerificationProps } from "@/types/components/blocks/dynamicC
|
||||
export default async function SignUpVerification({
|
||||
dynamic_content,
|
||||
}: SignUpVerificationProps) {
|
||||
const user = await getProfileSafely()
|
||||
if (user) {
|
||||
const session = await auth()
|
||||
if (isValidSession(session)) {
|
||||
redirect(overview[getLang()])
|
||||
}
|
||||
const intl = await getIntl()
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
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"
|
||||
import { isValidSession } from "@/utils/session"
|
||||
|
||||
import type { SignupFormWrapperProps } from "@/types/components/blocks/dynamicContent"
|
||||
|
||||
export default async function SignupFormWrapper({
|
||||
dynamic_content,
|
||||
}: SignupFormWrapperProps) {
|
||||
const user = await getProfileSafely()
|
||||
if (user) {
|
||||
const session = await auth()
|
||||
if (isValidSession(session)) {
|
||||
// We don't want to allow users to access signup if they are already authenticated.
|
||||
redirect(overview[getLang()])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user