Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { useEffect } from 'react'
import { getLogoutURL, AuthIsDisabled } from '../../lib/auth'
import { authOptions } from '../../pages/api/auth/[...nextauth]'
import { getServerSession } from 'next-auth/next'
import LoadingSpinner from '../../components/LoadingSpinner'
import { signOut } from 'next-auth/react'
import MetaData from '../../components/MetaData'
import { getLogger } from '../../logging/log-util'
export default function Logout(props) {
//Redirect to ECAS global sign out
useEffect(() => {
const logout = async () => {
await signOut({ redirect: false })
window.location.replace(props.logoutURL)
}
logout().catch(console.error)
}, [props.logoutURL])
return (
<div role="main">
<MetaData language="en" data={props.meta}></MetaData>
<h1
className="grid h-screen place-items-center"
data-cy="loading-spinner"
aria-live="polite"
aria-busy="true"
>
<LoadingSpinner text="Loading / Chargement en cours ..." />
</h1>
</div>
)
}
Logout.getLayout = function PageLayout(page) {
return <>{page}</>
}
export async function getServerSideProps({ req, res, locale }) {
const session = await getServerSession(req, res, authOptions)
//The below sets the minimum logging level to error and surpresses everything below that
const logger = getLogger('logout')
logger.level = 'error'
const logoutURL = !AuthIsDisabled()
? await getLogoutURL(req, session, locale).catch((error) => {
logger.error(error)
res.statusCode = 500
throw error
})
: '/'
/* Place-holder Meta Data Props */
const meta = {
data_en: {
title: 'Loading-Chargement en cours - Canada.ca',
desc: 'English',
author: 'Service Canada',
keywords: '',
service: 'ESDC-EDSC_MSCA-MSDC-SCH',
creator: 'Employment and Social Development Canada',
accessRights: '1',
},
data_fr: {
title: 'Loading-Chargement en cours - Canada.ca',
desc: 'Français',
author: 'Service Canada',
keywords: '',
service: 'ESDC-EDSC_MSCA-MSDC-SCH',
creator: 'Emploi et Développement social Canada',
accessRights: '1',
},
}
return {
props: {
locale,
meta,
logoutURL: logoutURL ?? '/',
},
}
}
|