diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx index cefc128..d3d6035 100644 --- a/app/(auth)/login/page.tsx +++ b/app/(auth)/login/page.tsx @@ -1,3 +1,4 @@ +import { ForbiddenError } from '@/domain/errors'; import { GetUser } from '@/application/server'; import { LoginForm } from '@/presentation/components/auth/login'; import { Metadata } from 'next'; @@ -23,7 +24,9 @@ export default async function LoginPage({ searchParams }: Props) { try { user = await getUser.execute(); } catch (error) { - // Do nothing + if (error instanceof ForbiddenError && error.message.includes('not verified')) { + redirect(`/verify-email?callback_url=${searchParams.callback_url}`); + } } if (user) { diff --git a/app/(auth)/register/page.tsx b/app/(auth)/register/page.tsx index cfca608..8415528 100644 --- a/app/(auth)/register/page.tsx +++ b/app/(auth)/register/page.tsx @@ -1,3 +1,4 @@ +import { ForbiddenError } from '@/domain/errors'; import { GetUser } from '@/application/server'; import { Metadata } from 'next'; import { redirect } from 'next/navigation'; @@ -23,7 +24,9 @@ export default async function RegisterPage({ searchParams }: Props) { try { user = await getUser.execute(); } catch (error) { - // Do nothing + if (error instanceof ForbiddenError && error.message.includes('not verified')) { + redirect(`/verify-email?callback_url=${searchParams.callback_url}`); + } } if (user) { diff --git a/app/(auth)/reset-password/page.tsx b/app/(auth)/reset-password/page.tsx index e590879..d5eff79 100644 --- a/app/(auth)/reset-password/page.tsx +++ b/app/(auth)/reset-password/page.tsx @@ -1,3 +1,4 @@ +import { ForbiddenError } from '@/domain/errors'; import { GetUser } from '@/application/server'; import { Metadata } from 'next'; import { redirect } from 'next/navigation'; @@ -8,6 +9,7 @@ import { import { Symbols } from '@/config/symbols'; import { serverContainer } from '@/server-injection'; import { User } from '@/domain/entities'; + export const metadata: Metadata = { title: 'Atur Ulang Kata Sandi', }; @@ -27,7 +29,9 @@ export default async function ResetPasswordPage({ searchParams }: Props) { try { user = await getUser.execute(); } catch (error) { - // Do nothing + if (error instanceof ForbiddenError && error.message.includes('not verified')) { + redirect(`/verify-email?callback_url=${searchParams.callback_url}`); + } } if (user) {