forked from HamedBahram/nextjs-13
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58bf2b6
commit 24eb64f
Showing
11 changed files
with
273 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use client' | ||
|
||
import { useSession, signIn, signOut } from 'next-auth/react' | ||
|
||
const LoginButton = () => { | ||
const { data: session } = useSession() | ||
if (session) { | ||
return ( | ||
<button | ||
className='text-sm font-medium tracking-wider uppercase text-stone-500' | ||
onClick={() => signOut()} | ||
> | ||
Sign Out | ||
</button> | ||
) | ||
} | ||
|
||
return ( | ||
<button | ||
className='text-sm font-medium tracking-wider uppercase text-stone-500' | ||
onClick={() => signIn()} | ||
> | ||
Sign In | ||
</button> | ||
) | ||
} | ||
|
||
export default LoginButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use client' | ||
|
||
import { SessionProvider } from 'next-auth/react' | ||
|
||
const Provider = ({ children }) => { | ||
return <SessionProvider>{children}</SessionProvider> | ||
} | ||
|
||
export default Provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
|
||
const prisma = new PrismaClient() | ||
export default prisma | ||
const client = globalThis.prisma || new PrismaClient() | ||
if (process.env.NODE_ENV !== 'production') globalThis.prisma = client | ||
|
||
export default client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import NextAuth from 'next-auth' | ||
import prisma from '@/lib/prisma' | ||
import GoogleProvider from 'next-auth/providers/google' | ||
import { PrismaAdapter } from '@next-auth/prisma-adapter' | ||
|
||
export default async function auth(req, res) { | ||
return await NextAuth(req, res, { | ||
providers: [ | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_CLIENT_ID, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET | ||
}) | ||
], | ||
pages: { | ||
// signIn: '/signin' | ||
}, | ||
adapter: PrismaAdapter(prisma), | ||
session: { | ||
strategy: 'jwt' | ||
} | ||
}) | ||
} |
Oops, something went wrong.