Skip to content

Commit

Permalink
fix: authOptions export in route.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeherby committed Feb 25, 2024
1 parent 260e15e commit 163708d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
21 changes: 3 additions & 18 deletions ui/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -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 };
4 changes: 2 additions & 2 deletions ui/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/global/app-bar/app-bar.tsx
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down
16 changes: 16 additions & 0 deletions ui/src/lib/utils/auth-options.ts
Original file line number Diff line number Diff line change
@@ -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',
},
},
}),
],
};

0 comments on commit 163708d

Please sign in to comment.