mirror of
https://github.com/detleph/server.git
synced 2026-09-09 16:06:21 +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 { AUTH_ERROR, createInsufficientPermissionsError, DataType, generateInvalidBodyError } from "./common";
|
||||||
import { authClient } from "../lib/redis";
|
import { authClient } from "../lib/redis";
|
||||||
|
|
||||||
|
require("express-async-errors");
|
||||||
|
|
||||||
export const regenerateRevision = async (pid: string) => {
|
export const regenerateRevision = async (pid: string) => {
|
||||||
// TOOO: Add error handling
|
// TOOO: Add error handling
|
||||||
const { revision } = await prisma.admin.update({
|
const { revision } = await prisma.admin.update({
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
handleCreateByName,
|
handleCreateByName,
|
||||||
} from "./common";
|
} from "./common";
|
||||||
|
|
||||||
|
require("express-async-errors");
|
||||||
|
|
||||||
const updateGroupBody = z
|
const updateGroupBody = z
|
||||||
.object({
|
.object({
|
||||||
name: z.string().min(1),
|
name: z.string().min(1),
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
|
|||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import NotFoundError from "../Middleware/error/NotFoundError";
|
import NotFoundError from "../Middleware/error/NotFoundError";
|
||||||
|
|
||||||
|
require("express-async-errors");
|
||||||
|
|
||||||
function validateOranisationName(name: string) {
|
function validateOranisationName(name: string) {
|
||||||
return name.length > 0;
|
return name.length > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import NotFoundError from "../Middleware/error/NotFoundError";
|
|||||||
import { requireLeaderOfTeam, requireResponsibleForParticipant } from "../Middleware/auth/teamleaderAuth";
|
import { requireLeaderOfTeam, requireResponsibleForParticipant } from "../Middleware/auth/teamleaderAuth";
|
||||||
import { requireResponsibleForGroups } from "../Middleware/auth/auth";
|
import { requireResponsibleForGroups } from "../Middleware/auth/auth";
|
||||||
|
|
||||||
|
require("express-async-errors");
|
||||||
|
|
||||||
const InitialParticipant = z.object({
|
const InitialParticipant = z.object({
|
||||||
firstName: z.string(),
|
firstName: z.string(),
|
||||||
lastName: z.string(),
|
lastName: z.string(),
|
||||||
@@ -104,7 +106,7 @@ export const updateParticipant = async (req: Request<{ pid: string }>, res: Resp
|
|||||||
const { pid } = req.params;
|
const { pid } = req.params;
|
||||||
|
|
||||||
if (req.teamleader?.isAuthenticated) {
|
if (req.teamleader?.isAuthenticated) {
|
||||||
requireResponsibleForParticipant(req.teamleader, pid);
|
await requireResponsibleForParticipant(req.teamleader, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = InitialParticipant.partial().safeParse(req.body);
|
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;
|
const { pid } = req.params;
|
||||||
|
|
||||||
if (req.teamleader?.isAuthenticated) {
|
if (req.teamleader?.isAuthenticated) {
|
||||||
requireResponsibleForParticipant(req.teamleader, pid);
|
await requireResponsibleForParticipant(req.teamleader, pid);
|
||||||
} else {
|
} else {
|
||||||
await requireResponsibleForGroups(req.auth, await getGroupByParticipantPid(pid));
|
requireResponsibleForGroups(req.auth, await getGroupByParticipantPid(pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import {
|
|||||||
validateName,
|
validateName,
|
||||||
} from "./common";
|
} from "./common";
|
||||||
|
|
||||||
|
require("express-async-errors");
|
||||||
|
|
||||||
const RoleSchemaBody = z.object({
|
const RoleSchemaBody = z.object({
|
||||||
name: z.string().min(1),
|
name: z.string().min(1),
|
||||||
schema: z.string(),
|
schema: z.string(),
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import { TeamBody } from "./user_auth.controller";
|
|||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import NotFoundError from "../Middleware/error/NotFoundError";
|
import NotFoundError from "../Middleware/error/NotFoundError";
|
||||||
import { requireResponsibleForGroups } from "../Middleware/auth/auth";
|
import { requireResponsibleForGroups } from "../Middleware/auth/auth";
|
||||||
|
import AuthError from "../Middleware/error/AuthError";
|
||||||
|
|
||||||
|
require("express-async-errors");
|
||||||
|
|
||||||
export const basicTeam = {
|
export const basicTeam = {
|
||||||
pid: true,
|
pid: true,
|
||||||
@@ -108,8 +111,10 @@ export const deleteTeam = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
if (req.teamleader?.isAuthenticated) {
|
if (req.teamleader?.isAuthenticated) {
|
||||||
await requireLeaderOfTeam(req.teamleader, pid);
|
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 } });
|
await prisma.team.delete({ where: { pid } });
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { generateTeamleaderJWT } from "../Middleware/auth/teamleaderAuth";
|
|||||||
import { createRolesForTeam } from "./role.controller";
|
import { createRolesForTeam } from "./role.controller";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
require("express-async-errors");
|
||||||
|
|
||||||
export const TeamBody = z.object({
|
export const TeamBody = z.object({
|
||||||
teamName: z.string().min(1),
|
teamName: z.string().min(1),
|
||||||
leaderEmail: z.string().email(),
|
leaderEmail: z.string().email(),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import jwt, { JsonWebTokenError } from "jsonwebtoken";
|
|||||||
import AuthError from "../error/AuthError";
|
import AuthError from "../error/AuthError";
|
||||||
import { getBearerToken, verifyAuthorizationFormat } from "./auth";
|
import { getBearerToken, verifyAuthorizationFormat } from "./auth";
|
||||||
import prisma from "../../lib/prisma";
|
import prisma from "../../lib/prisma";
|
||||||
|
import { checkTeamExistence } from "../../Controllers/team.controller";
|
||||||
|
|
||||||
export interface TeamleaderJWTPayload {
|
export interface TeamleaderJWTPayload {
|
||||||
team: string;
|
team: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user