Fix routes, add getRole controller

This commit is contained in:
Stephan
2022-06-09 16:23:54 +02:00
committed by La_Felx
parent 87f5fa2e91
commit 718c040517
5 changed files with 68 additions and 15 deletions
+8 -1
View File
@@ -1,6 +1,6 @@
import { Request, Response } from "express";
import prisma from "../lib/prisma";
import { DataType, generateInvalidBodyError } from "./common";
import { createInsufficientPermissionsError, DataType, generateInvalidBodyError } from "./common";
import { requireLeaderOfTeam } from "../Middleware/auth/teamleaderAuth";
import { TeamBody } from "./user_auth.controller";
import { Prisma } from "@prisma/client";
@@ -88,6 +88,13 @@ export const updateTeam = async (req: Request, res: Response) => {
const body = result.data;
try {
requireLeaderOfTeam(req.teamleader, pid);
} catch {
// TODO: DO NOT CATCH THESE ERRORS
return res.status(401).json(createInsufficientPermissionsError("STANDARD"));
}
try {
const team = await prisma.team.update({
where: {