Add 401 page (#1508)

This commit is contained in:
Manuel
2023-10-27 23:10:42 +02:00
committed by GitHub
parent 4072ebc5a5
commit 5b3a236194
11 changed files with 107 additions and 46 deletions

View File

@@ -4,7 +4,9 @@ import {
GetServerSidePropsResult,
PreviewData,
} from 'next';
import { Session } from 'next-auth';
import { ParsedUrlQuery } from 'querystring';
export const checkForSessionOrAskForLogin = (
@@ -13,7 +15,6 @@ export const checkForSessionOrAskForLogin = (
accessCallback: () => boolean
): GetServerSidePropsResult<any> | undefined => {
if (!session?.user) {
console.log('detected logged out user!');
return {
props: {},
redirect: {
@@ -26,7 +27,10 @@ export const checkForSessionOrAskForLogin = (
if (!accessCallback()) {
return {
props: {},
notFound: true,
redirect: {
destination: '/401',
permanent: false
}
};
}

View File

@@ -51,3 +51,5 @@ export const manageNamespaces = [
export const loginNamespaces = ['authentication/login'];
export const pageNotFoundNamespaces = ['layout/errors/not-found'];
export const pageAccessDeniedNamespaces = ['layout/errors/access-denied'];