mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
small fixes
This commit is contained in:
@@ -5,6 +5,8 @@ import argon2 from "argon2";
|
||||
import { AUTH_ERROR, createInsufficientPermissionsError, DataType, generateInvalidBodyError } from "./common";
|
||||
import { authClient } from "../lib/redis";
|
||||
|
||||
require("express-async-errors");
|
||||
|
||||
export const regenerateRevision = async (pid: string) => {
|
||||
// TOOO: Add error handling
|
||||
const { revision } = await prisma.admin.update({
|
||||
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
handleCreateByName,
|
||||
} from "./common";
|
||||
|
||||
require("express-async-errors");
|
||||
|
||||
const updateGroupBody = z
|
||||
.object({
|
||||
name: z.string().min(1),
|
||||
|
||||
@@ -14,6 +14,8 @@ import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import NotFoundError from "../Middleware/error/NotFoundError";
|
||||
|
||||
require("express-async-errors");
|
||||
|
||||
function validateOranisationName(name: string) {
|
||||
return name.length > 0;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import NotFoundError from "../Middleware/error/NotFoundError";
|
||||
import { requireLeaderOfTeam, requireResponsibleForParticipant } from "../Middleware/auth/teamleaderAuth";
|
||||
import { requireResponsibleForGroups } from "../Middleware/auth/auth";
|
||||
|
||||
require("express-async-errors");
|
||||
|
||||
const InitialParticipant = z.object({
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
@@ -104,7 +106,7 @@ export const updateParticipant = async (req: Request<{ pid: string }>, res: Resp
|
||||
const { pid } = req.params;
|
||||
|
||||
if (req.teamleader?.isAuthenticated) {
|
||||
requireResponsibleForParticipant(req.teamleader, pid);
|
||||
await requireResponsibleForParticipant(req.teamleader, pid);
|
||||
}
|
||||
|
||||
const result = InitialParticipant.partial().safeParse(req.body);
|
||||
@@ -153,9 +155,9 @@ export const deleteParticipant = async (req: Request<{ pid: string }>, res: Resp
|
||||
const { pid } = req.params;
|
||||
|
||||
if (req.teamleader?.isAuthenticated) {
|
||||
requireResponsibleForParticipant(req.teamleader, pid);
|
||||
await requireResponsibleForParticipant(req.teamleader, pid);
|
||||
} else {
|
||||
await requireResponsibleForGroups(req.auth, await getGroupByParticipantPid(pid));
|
||||
requireResponsibleForGroups(req.auth, await getGroupByParticipantPid(pid));
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
validateName,
|
||||
} from "./common";
|
||||
|
||||
require("express-async-errors");
|
||||
|
||||
const RoleSchemaBody = z.object({
|
||||
name: z.string().min(1),
|
||||
schema: z.string(),
|
||||
|
||||
@@ -6,6 +6,9 @@ import { TeamBody } from "./user_auth.controller";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import NotFoundError from "../Middleware/error/NotFoundError";
|
||||
import { requireResponsibleForGroups } from "../Middleware/auth/auth";
|
||||
import AuthError from "../Middleware/error/AuthError";
|
||||
|
||||
require("express-async-errors");
|
||||
|
||||
export const basicTeam = {
|
||||
pid: true,
|
||||
@@ -108,8 +111,10 @@ export const deleteTeam = async (req: Request, res: Response) => {
|
||||
|
||||
if (req.teamleader?.isAuthenticated) {
|
||||
await requireLeaderOfTeam(req.teamleader, pid);
|
||||
} else {
|
||||
await requireResponsibleForGroups(req.auth, await getGroupsByTeamPid(pid));
|
||||
}
|
||||
|
||||
if (req.auth?.permission_level == "STANDARD") {
|
||||
throw new AuthError("STANDARD Admins are not allowed to delete Teams!")
|
||||
}
|
||||
|
||||
await prisma.team.delete({ where: { pid } });
|
||||
|
||||
@@ -8,6 +8,8 @@ import { generateTeamleaderJWT } from "../Middleware/auth/teamleaderAuth";
|
||||
import { createRolesForTeam } from "./role.controller";
|
||||
import { z } from "zod";
|
||||
|
||||
require("express-async-errors");
|
||||
|
||||
export const TeamBody = z.object({
|
||||
teamName: z.string().min(1),
|
||||
leaderEmail: z.string().email(),
|
||||
|
||||
Reference in New Issue
Block a user