Skip to content

Commit

Permalink
ar(lint)
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloreale committed Feb 8, 2024
1 parent 2723fdc commit 1267476
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 82 deletions.
10 changes: 4 additions & 6 deletions lib/auth/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
37 changes: 0 additions & 37 deletions src/app/error/page.tsx
Original file line number Diff line number Diff line change
@@ -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<ISignInData> {
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 (
<main className={styles.main}>
<article>
Expand Down
4 changes: 2 additions & 2 deletions src/app/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<main className={styles.main}>
<article>
Expand Down
37 changes: 0 additions & 37 deletions src/app/verify/page.tsx
Original file line number Diff line number Diff line change
@@ -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<ISignInData> {
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 (
<main className={styles.main}>
<article>
Expand Down

0 comments on commit 1267476

Please sign in to comment.