fix: teacher invitations middelware en questions

This commit is contained in:
Gabriellvl 2025-05-09 18:08:44 +02:00
parent e799705a09
commit c054eb9335
4 changed files with 18 additions and 7 deletions

View file

@ -1,11 +1,11 @@
import express from 'express';
import { createAnswerHandler, deleteAnswerHandler, getAnswerHandler, getAllAnswersHandler, updateAnswerHandler } from '../controllers/answers.js';
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks.js';
import {adminOnly, authenticatedOnly, teachersOnly} from '../middleware/auth/checks/auth-checks.js';
import { onlyAllowAuthor, onlyAllowAuthorRequestAnswer, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks.js';
const router = express.Router({ mergeParams: true });
router.get('/', adminOnly, getAllAnswersHandler);
router.get('/', authenticatedOnly, getAllAnswersHandler);
router.post('/', teachersOnly, onlyAllowAuthor, createAnswerHandler);

View file

@ -15,7 +15,7 @@ import {
} from '../controllers/classes.js';
import assignmentRouter from './assignments.js';
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks.js';
import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks.js';
import {onlyAllowIfInClass, onlyAllowIfInClassOrInvited} from '../middleware/auth/checks/class-auth-checks.js';
const router = express.Router();
@ -23,7 +23,7 @@ router.get('/', adminOnly, getAllClassesHandler);
router.post('/', teachersOnly, createClassHandler);
router.get('/:id', onlyAllowIfInClass, getClassHandler);
router.get('/:id', onlyAllowIfInClassOrInvited, getClassHandler);
router.put('/:id', teachersOnly, onlyAllowIfInClass, putClassHandler);

View file

@ -1,7 +1,7 @@
import express from 'express';
import { createQuestionHandler, deleteQuestionHandler, getAllQuestionsHandler, getQuestionHandler } from '../controllers/questions.js';
import answerRoutes from './answers.js';
import { adminOnly, studentsOnly } from '../middleware/auth/checks/auth-checks.js';
import {adminOnly, authenticatedOnly, studentsOnly} from '../middleware/auth/checks/auth-checks.js';
import { updateAnswerHandler } from '../controllers/answers.js';
import { onlyAllowAuthor, onlyAllowAuthorRequest, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks.js';
@ -10,9 +10,9 @@ const router = express.Router({ mergeParams: true });
// Query language
// Root endpoint used to search objects
router.get('/', adminOnly, getAllQuestionsHandler);
router.get('/', authenticatedOnly, getAllQuestionsHandler);
router.post('/', studentsOnly, onlyAllowAuthor, createQuestionHandler);
router.post('/', studentsOnly, onlyAllowAuthor, createQuestionHandler); // TODO part of group
// Information about a question with id
router.get('/:seq', onlyAllowIfHasAccessToQuestion, getQuestionHandler);