diff --git a/lib/auth/constants.ts b/lib/auth/constants.ts index 2d31f11f..362344e5 100644 --- a/lib/auth/constants.ts +++ b/lib/auth/constants.ts @@ -39,14 +39,12 @@ export const authOptions: AuthOptions = { }, }, callbacks: { - async signIn({ user, account, profile, email, credentials }) { + async signIn() { // extra sign-in checks - return true + return true; }, - async redirect ({url, baseUrl}) { - return url.startsWith(baseUrl) - ? Promise.resolve(url) - : Promise.resolve(baseUrl) + async redirect({ url, baseUrl }) { + return url.startsWith(baseUrl) ? Promise.resolve(url) : Promise.resolve(baseUrl); }, async jwt({ user, token }) { if (user) { diff --git a/src/app/error/page.tsx b/src/app/error/page.tsx index 4a8c89f8..f12ea2e5 100644 --- a/src/app/error/page.tsx +++ b/src/app/error/page.tsx @@ -1,45 +1,8 @@ // signin/page.tsx TS-Doc? 'use server'; -import { getProviders, getCsrfToken } from 'next-auth/react'; -import { getServerSession } from 'next-auth/next'; -import { redirect } from 'next/navigation'; -import { cookies } from 'next/headers'; -import { authOptions } from '@auth'; -import { VSignUp } from '@components/client'; import styles from '@styles/page.module.css'; -interface ISignInData { - providers?: IAuthProviders[]; - redirect?: { - destination?: string; - }; -} - -interface IAuthProviders { - id?: string; - name?: string; -} - -async function getProvidersData(): Promise { - const session = await getServerSession(authOptions); - - // If the user is already logged in, redirect. - // Note: Make sure not to redirect to the same page - // To avoid an infinite loop! - if (session) { - return redirect(process.env.NEXUS_BASE_PATH || '/'); - } - - const providers = (await getProviders()) as unknown as IAuthProviders[]; - - return { providers: providers ?? [] }; -} - export default async function SignUp() { - const props: ISignInData = await getProvidersData(); - const providers: IAuthProviders[] = props?.providers || []; - cookies(); - const csrf: string | undefined = await getCsrfToken(); return (
diff --git a/src/app/signin/page.tsx b/src/app/signin/page.tsx index 4686768e..9865d384 100644 --- a/src/app/signin/page.tsx +++ b/src/app/signin/page.tsx @@ -42,12 +42,12 @@ export default async function SignUp() { const cookieCsrf: string | undefined = await getCsrfToken({ req: { headers: { - cookie: cookies().toString(), + cookie: cook.toString(), }, }, }); const newCsrf: string | undefined = await getCsrfToken(); - const csrf = cookieCsrf || newCsrf + const csrf = cookieCsrf || newCsrf; return (
diff --git a/src/app/verify/page.tsx b/src/app/verify/page.tsx index faebffc9..2621ce95 100644 --- a/src/app/verify/page.tsx +++ b/src/app/verify/page.tsx @@ -1,45 +1,8 @@ // signin/page.tsx TS-Doc? 'use server'; -import { getProviders, getCsrfToken } from 'next-auth/react'; -import { getServerSession } from 'next-auth/next'; -import { redirect } from 'next/navigation'; -import { cookies } from 'next/headers'; -import { authOptions } from '@auth'; -import { VSignUp } from '@components/client'; import styles from '@styles/page.module.css'; -interface ISignInData { - providers?: IAuthProviders[]; - redirect?: { - destination?: string; - }; -} - -interface IAuthProviders { - id?: string; - name?: string; -} - -async function getProvidersData(): Promise { - const session = await getServerSession(authOptions); - - // If the user is already logged in, redirect. - // Note: Make sure not to redirect to the same page - // To avoid an infinite loop! - if (session) { - return redirect(process.env.NEXUS_BASE_PATH || '/'); - } - - const providers = (await getProviders()) as unknown as IAuthProviders[]; - - return { providers: providers ?? [] }; -} - export default async function SignUp() { - const props: ISignInData = await getProvidersData(); - const providers: IAuthProviders[] = props?.providers || []; - cookies(); - const csrf: string | undefined = await getCsrfToken(); return (