mirror of
https://github.com/detleph/server.git
synced 2026-09-07 07:56:18 +02:00
Add authorization
This commit is contained in:
@@ -79,20 +79,24 @@ export const getEvent = async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// requires: auth(ELEVATED)
|
||||||
export const addEvent = async (req: Request, res: Response) => {
|
export const addEvent = async (req: Request, res: Response) => {
|
||||||
|
if (req.auth?.permission_level !== "ELEVATED") {
|
||||||
|
res.status(403).json(createInsufficientPermissionsError());
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof req.body.name !== "string" ||
|
typeof req.body.name !== "string" ||
|
||||||
typeof req.body.date !== "string" ||
|
typeof req.body.date !== "string" ||
|
||||||
typeof req.body.description !== "string"
|
typeof req.body.description !== "string"
|
||||||
) {
|
) {
|
||||||
res.status(400).json(
|
return res.status(400).json(
|
||||||
generateInvalidBodyError({
|
generateInvalidBodyError({
|
||||||
name: DataType.STRING,
|
name: DataType.STRING,
|
||||||
date: DataType.DATETIME,
|
date: DataType.DATETIME,
|
||||||
description: DataType.STRING,
|
description: DataType.STRING,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Check if date is valid
|
//TODO: Check if date is valid
|
||||||
|
|||||||
Reference in New Issue
Block a user