Skip to content

Commit

Permalink
role based authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar98644 committed Jul 11, 2023
1 parent 0513871 commit 06fabec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
21 changes: 17 additions & 4 deletions src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,23 @@ const Navbar = () => {
<>
<nav className='col-span-3 md:block hidden'>
<ul className='md:grid grid-cols-3 hidden xl:text-xl lg:text-lg text-nav-text cursor-pointer hover:transition items-center gap-6'>
{session ? (
<><li className='hover:text-white'><Link href='/project'>Add project</Link></li><li className='hover:text-white'><Link href='/'>View Projects</Link></li><li className='hover:text-white'><Link href='/admin'>Admin Panel</Link></li></>
) : (
null
{session && (
<>
{session?.user?.email === process.env.NEXT_PUBLIC_ADMIN_EMAIL ? (
<><li className='hover:text-white'><Link href='/project'>Add project</Link></li><li className='hover:text-white'><Link href='/'>View Projects</Link></li><li className='hover:text-white'>
<Link href='/admin'>
Admin Panel
</Link>
</li></>
) : (
<><li className='hover:text-white'><Link href='/project'>Add project</Link></li><li className='hover:text-white'><Link href='/'>View Projects</Link></li><li className='hover:text-white'>
<Link href='/admin'>
Contact Admin
</Link>
</li></>
)
}
</>
)}
</ul>
</nav>
Expand Down
6 changes: 4 additions & 2 deletions src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ export const authOptions = {
clientSecret: process.env.GITHUB_SECRET as string,
}),
GoogleProvider({
clientId: process.env.GOOGLE_ID as string,
clientSecret: process.env.GOOGLE_SECRET as string,
clientId: process.env.GOOGLE_ID as string,
clientSecret: process.env.GOOGLE_SECRET as string,
}),

],
secret: process.env.SECRET,
adapter: MongoDBAdapter(clientPromise),
}


export default NextAuth(authOptions)

0 comments on commit 06fabec

Please sign in to comment.