Browse Source

No credentials signin has same format as normal http 400.

Signed-off-by: Chunwea Woo <chw644@hotmail.com>
pull/1274/head
LancerComet 3 years ago committed by Chunwea Woo
parent
commit
850083b0f1
  1. 7
      packages/nocodb/src/__tests__/rest.test.ts
  2. 24
      packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts

7
packages/nocodb/src/__tests__/rest.test.ts

@ -190,6 +190,13 @@ describe('{Auth, CRUD, HasMany, Belongs} Tests', () => {
.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)
.post('/auth/password/forgot')

24
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);

Loading…
Cancel
Save