diff --git a/ui/src/app/api/auth/[...nextauth]/route.ts b/ui/src/app/api/auth/[...nextauth]/route.ts index 7b285bd..3ea5f26 100644 --- a/ui/src/app/api/auth/[...nextauth]/route.ts +++ b/ui/src/app/api/auth/[...nextauth]/route.ts @@ -1,20 +1,5 @@ -import NextAuth, { NextAuthOptions, Profile } from 'next-auth'; -import GithubProvider from 'next-auth/providers/github'; - -const authOptions: NextAuthOptions = { - providers: [ - GithubProvider({ - clientId: process.env.NEXTAUTH_GITHUB_ID!, - clientSecret: process.env.NEXTAUTH_GITHUB_SECRET!, - authorization: { - params: { - scope: 'read:user,user:email,read:org', - }, - }, - }), - ], -}; - +import { authOptions } from '@/lib/utils/auth-options'; +import NextAuth from 'next-auth'; const handler = NextAuth(authOptions); -export { handler as GET, handler as POST, authOptions }; +export { handler as GET, handler as POST }; diff --git a/ui/src/app/page.tsx b/ui/src/app/page.tsx index 46e407c..9df2b5d 100644 --- a/ui/src/app/page.tsx +++ b/ui/src/app/page.tsx @@ -1,9 +1,9 @@ import { getServerSession } from 'next-auth'; -import { authOptions } from '@/app/api/auth/[...nextauth]/route'; import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'; import { buttonVariants } from '@/components/ui/button'; import Link from 'next/link'; -import { BarChartIcon, GearIcon, StackIcon } from '@radix-ui/react-icons'; +import { BarChartIcon, StackIcon } from '@radix-ui/react-icons'; +import { authOptions } from '@/lib/utils/auth-options'; const quickLinks = [ diff --git a/ui/src/components/global/app-bar/app-bar.tsx b/ui/src/components/global/app-bar/app-bar.tsx index 9a805fc..8edb511 100644 --- a/ui/src/components/global/app-bar/app-bar.tsx +++ b/ui/src/components/global/app-bar/app-bar.tsx @@ -1,11 +1,11 @@ import React from 'react'; import Breadcrumbs, { BreadcrumbItem } from '@/components/global/app-bar/breadcrumbs'; import { getServerSession } from 'next-auth'; -import { authOptions } from '@/app/api/auth/[...nextauth]/route'; import SignOutIconButton from '@/components/global/app-bar/sign-out-icon-button'; import ThemeToggle from '@/components/global/app-bar/theme-toggle'; import Link from 'next/link'; import { buttonVariants } from '@/components/ui/button'; +import { authOptions } from '@/lib/utils/auth-options'; interface AppBarProps { breadcrumbItems: BreadcrumbItem[]; diff --git a/ui/src/lib/utils/auth-options.ts b/ui/src/lib/utils/auth-options.ts new file mode 100644 index 0000000..c4a60f5 --- /dev/null +++ b/ui/src/lib/utils/auth-options.ts @@ -0,0 +1,16 @@ +import { NextAuthOptions } from 'next-auth'; +import GithubProvider from 'next-auth/providers/github'; + +export const authOptions: NextAuthOptions = { + providers: [ + GithubProvider({ + clientId: process.env.NEXTAUTH_GITHUB_ID!, + clientSecret: process.env.NEXTAUTH_GITHUB_SECRET!, + authorization: { + params: { + scope: 'read:user,user:email,read:org', + }, + }, + }), + ], +};