Skip to content

Commit

Permalink
Merge pull request #185 from rit-sse/nextauth-type-fix
Browse files Browse the repository at this point in the history
Fixed nextauth typeerror and removed some unused imports. Build works now
  • Loading branch information
PokeJofeJr4th authored Oct 27, 2024
2 parents e0aa355 + 02fcc66 commit 929e638
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 24 deletions.
24 changes: 3 additions & 21 deletions next/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
import { PrismaAdapter } from "@auth/prisma-adapter";
import { PrismaClient } from "@prisma/client";
import NextAuth, { AuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { authOptions } from "@/lib/authOptions";
import NextAuth from "next-auth";

const prisma = new PrismaClient();

export const authOptions: AuthOptions = {
adapter: PrismaAdapter(prisma),
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
authorization: {
params: {
hd: "g.rit.edu", // restrict logins to rit.edu accounts
},
},
}),
],
};

export const handler = NextAuth(authOptions);
const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };
1 change: 0 additions & 1 deletion next/app/go/GoLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { GoLinkStar } from "@/components/common/Icons";
import { GoLinkEdit } from "@/components/common/Icons";
import { GoLinkDelete } from "@/components/common/Icons";
import { fetchAuthLevel, goLinksApi } from "@/lib/api";
import { useEffectAsync } from "@/lib/utils";
import { useSession } from "next-auth/react";
import { useCallback, useEffect, useState } from "react";

Expand Down
1 change: 0 additions & 1 deletion next/app/go/MakeNewGoLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useSession } from "next-auth/react";
import { use, useCallback, useEffect, useState } from "react";
import { CreateGoLinkProps } from "./page";
import { useEffectAsync } from "@/lib/utils";
import { goLinksApi, fetchAuthLevel } from "@/lib/api";

export const GoLinkButton: React.FC<CreateGoLinkProps> = ({ fetchData }) => {
Expand Down
2 changes: 1 addition & 1 deletion next/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Footer from "@/components/Footer";
import { Inter } from 'next/font/google'
import { Providers } from "./Providers";
import { getServerSession } from "next-auth";
import { authOptions } from "./api/auth/[...nextauth]/route";
import { authOptions } from '@/lib/authOptions';
import ScrollToTopButton from "@/components/nav/ScrollToTopButton";


Expand Down
21 changes: 21 additions & 0 deletions next/lib/authOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import { PrismaClient } from "@prisma/client";
import { AuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";

const prisma = new PrismaClient();

export const authOptions: AuthOptions = {
adapter: PrismaAdapter(prisma),
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
authorization: {
params: {
hd: "g.rit.edu", // restrict logins to rit.edu accounts
},
},
}),
],
};
11 changes: 11 additions & 0 deletions next/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"@auth/prisma-adapter": "^1.0.6",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.4.2",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
Expand Down

0 comments on commit 929e638

Please sign in to comment.