diff --git a/packages/nocodb/src/__tests__/rest.test.ts b/packages/nocodb/src/__tests__/rest.test.ts index 5cf8ea535c..b3b49383f3 100644 --- a/packages/nocodb/src/__tests__/rest.test.ts +++ b/packages/nocodb/src/__tests__/rest.test.ts @@ -189,6 +189,13 @@ describe('{Auth, CRUD, HasMany, Belongs} Tests', () => { .send({ email: EMAIL_ID, password: 'wrongPassword' }) .expect(400, done); }); + + it('Signup with no credentials', done => { + request(app) + .post('/auth/signin') + .send({}) + .expect(400, done) + }) it('Forgot password with a non-existing email id', function(done) { request(app) diff --git a/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts b/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts index dccf6bee61..378a5cdd9a 100644 --- a/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts +++ b/packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts @@ -635,7 +635,13 @@ export default class RestAuthCtrl { try { if (!user || !user.email) { if (err) { - return res.status(400).send(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 + }); } if (info) { return res.status(400).send(info); @@ -694,7 +700,13 @@ export default class RestAuthCtrl { try { if (!user || !user.email) { if (err) { - return res.status(400).send(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 + }); } if (info) { return res.status(400).send(info); @@ -753,7 +765,13 @@ export default class RestAuthCtrl { try { if (!user || !user.email) { if (err) { - return res.status(400).send(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 + }); } if (info) { return res.status(400).send(info);