Protect routes and procedures

This commit is contained in:
Manuel
2023-08-05 15:30:59 +02:00
parent 5b1b36eecc
commit cf057505ec
10 changed files with 209 additions and 43 deletions

View File

@@ -14,10 +14,13 @@ import {
import { useDebouncedValue } from '@mantine/hooks';
import { openContextModal } from '@mantine/modals';
import { IconPlus, IconTrash } from '@tabler/icons-react';
import { GetServerSideProps } from 'next';
import Head from 'next/head';
import Link from 'next/link';
import { useState } from 'react';
import { ManageLayout } from '~/components/layout/Templates/ManageLayout';
import { getServerAuthSession } from '~/server/auth';
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
import { api } from '~/utils/api';
const ManageUsersPage = () => {
@@ -134,4 +137,26 @@ const ManageUsersPage = () => {
);
};
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const session = await getServerAuthSession(ctx);
if (!session?.user.isAdmin) {
return {
notFound: true,
};
}
const translations = await getServerSideTranslations(
['common'],
ctx.locale,
undefined,
undefined
);
return {
props: {
...translations,
},
};
};
export default ManageUsersPage;