forked from ecss-soton/team-registration
-
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.
Merge pull request #7 from ecss-soton/restrict-signins
Restrict signins
- Loading branch information
Showing
4 changed files
with
84 additions
and
16 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
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,72 @@ | ||
import {unstable_getServerSession} from "next-auth"; | ||
import {LoginButton} from "@/components/LoginButton"; | ||
import {IncomingMessage, ServerResponse} from "http"; | ||
import {NextApiRequestCookies} from "next/dist/server/api-utils"; | ||
import {NextApiRequest, NextApiResponse} from "next"; | ||
import {authOptions} from "./api/auth/[...nextauth]"; | ||
import {Text, useMantineColorScheme} from "@mantine/core"; | ||
import {signIn, signOut, useSession} from "next-auth/react"; | ||
import {useRouter} from "next/router"; | ||
import Tables from "./seat-selection"; | ||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; | ||
import {faMicrosoft} from "@fortawesome/free-brands-svg-icons"; | ||
import React from "react"; | ||
|
||
// @ts-ignore | ||
export default function SignOut() { | ||
|
||
const router = useRouter(); | ||
|
||
const {data: session} = useSession(); | ||
|
||
const { colorScheme, toggleColorScheme } = useMantineColorScheme(); | ||
const dark = colorScheme === 'dark'; | ||
|
||
return ( | ||
<div className="flex flex-col items-center justify-center min-h-screen py-2"> | ||
|
||
<main className="flex flex-col items-center justify-center w-full flex-1 px-5 text-center"> | ||
|
||
<div className='flex flex-row justify-center'> | ||
{dark ? <img | ||
className='max-h-72' | ||
src="./WinterBallGF_1.png" | ||
alt="ECSS Winter ball logo" | ||
/> : <img | ||
className='max-h-72' | ||
src="./WinterBallGF_1.png" | ||
alt="ECSS Winter ball logo" | ||
/>} | ||
|
||
</div> | ||
|
||
<div onClick={() => signOut()} | ||
className="cursor-pointer h-11 w-64 text-white max-w-300 bg-[#005C85] hover:bg-[#024460] rounded-md flex p-3 flex-row items-center justify-center m-2"> | ||
<div className='flex-none pr-2'> | ||
<FontAwesomeIcon icon={faMicrosoft} className='text-white text-lg h-4 w-5'/> | ||
</div> | ||
Sign out | ||
</div> | ||
|
||
</main> | ||
</div> | ||
); | ||
} | ||
|
||
export async function getServerSideProps(context: { req: (IncomingMessage & { cookies: NextApiRequestCookies; }) | NextApiRequest; res: ServerResponse | NextApiResponse<any>; }) { | ||
|
||
const session = await unstable_getServerSession(context.req, context.res, authOptions) | ||
|
||
if (!session) { | ||
return { | ||
redirect: { | ||
destination: '/signin', | ||
permanent: false, | ||
}, | ||
} | ||
} | ||
|
||
return {props: {}} | ||
} | ||
|
||
SignOut.auth = true; |