Added permission to codes

This commit is contained in:
Joao Ramos
2024-08-07 10:03:17 +01:00
parent cf91f1812d
commit 0fc2df1070
6 changed files with 97 additions and 67 deletions

View File

@@ -14,6 +14,7 @@ import BatchCodeGenerator from "./(admin)/BatchCodeGenerator";
import {shouldRedirectHome} from "@/utils/navigation.disabled";
import ExamGenerator from "./(admin)/ExamGenerator";
import BatchCreateUser from "./(admin)/BatchCreateUser";
import { checkAccess, getTypesOfUser } from "@/utils/permissions";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
@@ -60,7 +61,7 @@ export default function Admin() {
<section className="w-full flex -md:flex-col -xl:gap-2 gap-8 justify-between">
<ExamLoader />
<BatchCreateUser user={user} />
{user.type !== "teacher" && (
{checkAccess(user, getTypesOfUser(["teacher"]), 'viewCodes') && (
<>
<CodeGenerator user={user} />
<BatchCodeGenerator user={user} />