File tree Expand file tree Collapse file tree 4 files changed +31
-18
lines changed
Expand file tree Collapse file tree 4 files changed +31
-18
lines changed Original file line number Diff line number Diff line change 1+ import { authOptions } from "@/app/auth/authOptions" ;
12import NextAuth from "next-auth" ;
2- import GoogleProvider from "next-auth/providers/google" ;
3- import { PrismaAdapter } from "@auth/prisma-adapter" ;
4- import prisma from "@/prisma/client" ;
53
6- const handler = NextAuth ( {
7- adapter : PrismaAdapter ( prisma ) ,
8- providers : [
9- GoogleProvider ( {
10- clientId : process . env . GOOGLE_CLIENT_ID ! ,
11- clientSecret : process . env . GOOGLE_CLIENT_SECRET ! ,
12- } ) ,
13- ] ,
14- } ) ;
4+ const handler = NextAuth ( authOptions ) ;
155
166export { handler as GET , handler as POST } ;
Original file line number Diff line number Diff line change 1+ import GoogleProvider from "next-auth/providers/google" ;
2+ import { PrismaAdapter } from "@auth/prisma-adapter" ;
3+ import prisma from "@/prisma/client" ;
4+
5+ export const authOptions = {
6+ adapter : PrismaAdapter ( prisma ) ,
7+ providers : [
8+ GoogleProvider ( {
9+ clientId : process . env . GOOGLE_CLIENT_ID ! ,
10+ clientSecret : process . env . GOOGLE_CLIENT_SECRET ! ,
11+ } ) ,
12+ ] ,
13+ } ;
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import { notFound } from "next/navigation";
44import EditIssueButton from "./EditIssueButton" ;
55import IssueDetails from "./IssueDetails" ;
66import DeleteIssueButton from "./DeleteIssueButton" ;
7+ import { getServerSession } from "next-auth" ;
8+ import { authOptions } from "@/app/auth/authOptions" ;
79
810interface Props {
911 params : Promise < {
@@ -12,6 +14,7 @@ interface Props {
1214}
1315
1416const IssueDetailPage = async ( { params } : Props ) => {
17+ const session = await getServerSession ( authOptions ) ;
1518 const { id } = await params ;
1619
1720 const issue = await prisma . issue . findUnique ( {
@@ -26,12 +29,14 @@ const IssueDetailPage = async ({ params }: Props) => {
2629 < Box className = "md:col-span-4" >
2730 < IssueDetails issue = { issue } />
2831 </ Box >
29- < Box >
30- < Flex direction = "column" gap = "4" >
31- < EditIssueButton issueId = { issue . id } />
32- < DeleteIssueButton issueId = { issue . id } />
33- </ Flex >
34- </ Box >
32+ { session && (
33+ < Box >
34+ < Flex direction = "column" gap = "4" >
35+ < EditIssueButton issueId = { issue . id } />
36+ < DeleteIssueButton issueId = { issue . id } />
37+ </ Flex >
38+ </ Box >
39+ ) }
3540 </ Grid >
3641 ) ;
3742} ;
Original file line number Diff line number Diff line change 1+ export { default } from "next-auth/middleware" ;
2+
3+ export const config = {
4+ matcher : [ ] ,
5+ } ;
You can’t perform that action at this time.
0 commit comments