-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
3 changed files
with
40 additions
and
6 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,6 @@ | ||
NEXTAUTH_URL=http://localhost:3000/ | ||
NEXTAUTH_SECRET=#use [openssl rand -hex 32] to generate a 32 bytes value | ||
|
||
AUTH0_CLIENT_ID=#client id | ||
AUTH0_CLIENT_SECRET=#client secret | ||
AUTH0_ISSUER=#issuer base url, example: example.us.auth0.com |
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,9 +1,37 @@ | ||
'use client'; | ||
import { Button } from '@mui/material'; | ||
import { useSession, signIn } from 'next-auth/react'; | ||
|
||
const AdminPage = () => { | ||
return ( | ||
<div className="flex flex-col px-5 min-h-screen"> | ||
<h1>Admin Page</h1> | ||
</div> | ||
); | ||
const { data: session } = useSession(); | ||
|
||
const handleLogin = () => signIn('auth0'); | ||
|
||
if (!session) { | ||
return ( | ||
<div className="flex flex-col items-center justify-center min-h-screen"> | ||
<div className="flex flex-col items-center justify-center px-6"> | ||
<h1 className="text-3xl">Vennligst logg inn</h1> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
title="Logg inn" | ||
onClick={() => handleLogin()} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
if (session?.user?.role !== 'admin') { | ||
return ( | ||
<div className="flex flex-col px-6"> | ||
<div className="flex items-center justify-center"> | ||
<h1 className="text-3xl">Du har ikke tilgang til denne siden</h1> | ||
</div> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
export default AdminPage; |
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