From cbb22e7441b79f4b403d4f485077334674779e58 Mon Sep 17 00:00:00 2001 From: LancerComet Date: Thu, 17 Feb 2022 21:51:38 +0800 Subject: [PATCH] Fix incorrect response while wrong credentials was provided Signed-off-by: Chunwea Woo --- .../nocodb/src/lib/noco/rest/RestAuthCtrl.ts | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts b/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts index 378a5cdd9a..14dc0bc02e 100644 --- a/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts +++ b/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts @@ -635,17 +635,19 @@ export default class RestAuthCtrl { try { if (!user || !user.email) { if (err) { - // This exception was thrown directly before. + // err: { msg: string } + return res.status(400).send(err); + } + if (info) { + // info: { message: string } + // Info was thrown directly before. // In order to avoid breaking change, both "msg" and "message" are returned. - const message = err.message ?? '' + const message = info.message ?? ''; return res.status(400).send({ msg: message, message }); } - if (info) { - return res.status(400).send(info); - } return res.status(400).send({ msg: 'Your signin has failed' }); } @@ -700,13 +702,7 @@ export default class RestAuthCtrl { try { if (!user || !user.email) { if (err) { - // This exception was thrown directly before. - // In order to avoid breaking change, both "msg" and "message" are returned. - const message = err.message ?? '' - return res.status(400).send({ - msg: message, - message - }); + return res.status(400).send(err); } if (info) { return res.status(400).send(info); @@ -765,13 +761,7 @@ export default class RestAuthCtrl { try { if (!user || !user.email) { if (err) { - // This exception was thrown directly before. - // In order to avoid breaking change, both "msg" and "message" are returned. - const message = err.message ?? '' - return res.status(400).send({ - msg: message, - message - }); + return res.status(400).send(err); } if (info) { return res.status(400).send(info);