From 94b53aff4c1d1023f749fa215cb156ddebad43da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Sun, 29 Aug 2021 17:24:50 +0200 Subject: [PATCH] API-25: Proper error for wrong content-type header --- src/models/partyplaner/login/Login.router.ts | 6 ++++++ src/models/partyplaner/register/Register.router.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/models/partyplaner/login/Login.router.ts b/src/models/partyplaner/login/Login.router.ts index e210d54..2f7c45c 100644 --- a/src/models/partyplaner/login/Login.router.ts +++ b/src/models/partyplaner/login/Login.router.ts @@ -36,6 +36,12 @@ loginRouter.post('/:isDevCall', async (req: Request, res: Response) => { username = (req.query.username ?? '').toString(); email = (req.query.email ?? '').toString(); password = (req.query.password ?? '').toString(); + } else { + res.status(400).send({ + 'status': 'WRONG_CONTENT_TYPE', + 'message': 'The transmitted content-type is not supported' + }); + return; } let userIP = req.socket.remoteAddress ?? ''; let deviceInfo = req.headers['user-agent'] ?? ''; diff --git a/src/models/partyplaner/register/Register.router.ts b/src/models/partyplaner/register/Register.router.ts index 34a91e1..60cbd31 100644 --- a/src/models/partyplaner/register/Register.router.ts +++ b/src/models/partyplaner/register/Register.router.ts @@ -42,6 +42,12 @@ registerRouter.post('/:isDevCall', async (req: Request, res: Response) => { firstName = (req.query.firstName ?? '').toString(); lastName = (req.query.lastName ?? '').toString(); password = (req.query.password ?? '').toString(); + } else { + res.status(400).send({ + 'status': 'WRONG_CONTENT_TYPE', + 'message': 'The transmitted content-type is not supported' + }); + return; } let userIP = req.socket.remoteAddress ?? ''; let deviceInfo = req.headers['user-agent'] ?? '';