diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index 7c62e2db..0aa1cd73 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -1,2 +1,2 @@ -import { handlers } from "@/auth"; +import { handlers } from '@/auth'; export const { GET, POST } = handlers; diff --git a/app/layout.tsx b/app/layout.tsx index 45786a87..682a1fbb 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,10 +1,10 @@ -import Providers from "@/components/layout/providers"; -import { Toaster } from "@/components/ui/toaster"; -import "@uploadthing/react/styles.css"; -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import "./globals.css"; -import { auth } from "@/auth"; +import Providers from '@/components/layout/providers'; +import { Toaster } from '@/components/ui/toaster'; +import '@uploadthing/react/styles.css'; +import type { Metadata } from 'next'; +import { Inter } from 'next/font/google'; +import './globals.css'; +import { auth } from '@/auth'; const inter = Inter({ subsets: ['latin'] }); diff --git a/auth.config.ts b/auth.config.ts index 179c2e78..250adb80 100644 --- a/auth.config.ts +++ b/auth.config.ts @@ -1,24 +1,28 @@ -import { NextAuthConfig } from "next-auth"; -import CredentialProvider from "next-auth/providers/credentials"; -import GithubProvider from "next-auth/providers/github"; +import { NextAuthConfig } from 'next-auth'; +import CredentialProvider from 'next-auth/providers/credentials'; +import GithubProvider from 'next-auth/providers/github'; const authConfig = { providers: [ GithubProvider({ clientId: process.env.GITHUB_ID ?? '', - clientSecret: process.env.GITHUB_SECRET ?? '', + clientSecret: process.env.GITHUB_SECRET ?? '' }), CredentialProvider({ credentials: { email: { - type: 'email', + type: 'email' }, password: { - type: 'password', + type: 'password' } }, async authorize(credentials, req) { - const user = { id: '1', name: 'John', email: credentials?.email as string }; + const user = { + id: '1', + name: 'John', + email: credentials?.email as string + }; if (user) { // Any object returned will be saved in `user` property of the JWT return user; @@ -32,8 +36,8 @@ const authConfig = { }) ], pages: { - signIn: "/", //sigin page - }, -} satisfies NextAuthConfig + signIn: '/' //sigin page + } +} satisfies NextAuthConfig; -export default authConfig +export default authConfig; diff --git a/auth.ts b/auth.ts index 0cc92316..f428227f 100644 --- a/auth.ts +++ b/auth.ts @@ -1,4 +1,4 @@ -import NextAuth from 'next-auth' -import authConfig from './auth.config' +import NextAuth from 'next-auth'; +import authConfig from './auth.config'; -export const { auth, handlers, signOut, signIn } = NextAuth(authConfig) +export const { auth, handlers, signOut, signIn } = NextAuth(authConfig); diff --git a/middleware.ts b/middleware.ts index 9f50d92d..bc17f507 100644 --- a/middleware.ts +++ b/middleware.ts @@ -2,16 +2,16 @@ // https://next-auth.js.org/configuration/nextjs#middleware // https://nextjs.org/docs/app/building-your-application/routing/middleware -import NextAuth from "next-auth"; -import authConfig from "./auth.config"; +import NextAuth from 'next-auth'; +import authConfig from './auth.config'; -const { auth } = NextAuth(authConfig) +const { auth } = NextAuth(authConfig); export default auth((req) => { if (!req.auth) { - const url = req.url.replace(req.nextUrl.pathname, "/"); + const url = req.url.replace(req.nextUrl.pathname, '/'); return Response.redirect(url); } }); -export const config = { matcher: ["/dashboard/:path*"] }; +export const config = { matcher: ['/dashboard/:path*'] }; diff --git a/types/next-auth.d.ts b/types/next-auth.d.ts index 59fea107..5afc7e1d 100644 --- a/types/next-auth.d.ts +++ b/types/next-auth.d.ts @@ -1,13 +1,13 @@ -import NextAuth, { DefaultSession } from 'next-auth' +import NextAuth, { DefaultSession } from 'next-auth'; declare module 'next-auth' { - type UserSession = DefaultSession['user'] + type UserSession = DefaultSession['user']; interface Session { - user: UserSession + user: UserSession; } interface CredentialsInputs { - email: string - password: string + email: string; + password: string; } }