Validation: respond with http 400 instead of 401

This commit is contained in:
Alice Gaudon 2020-11-15 14:12:45 +01:00
parent b28e2b75b7
commit 42da8a68bb
2 changed files with 4 additions and 4 deletions

View File

@ -102,16 +102,16 @@ export default abstract class Application implements Extendable<ApplicationCompo
const bag = err;
res.format({
json: () => {
res.status(401);
res.status(400);
res.json({
status: 'error',
code: 401,
code: 400,
message: 'Invalid form data',
messages: bag.getMessages(),
});
},
text: () => {
res.status(401);
res.status(400);
res.send('Error: ' + bag.getMessages());
},
html: () => {

View File

@ -135,7 +135,7 @@ describe('Register with username', () => {
password_confirmation: 'horde_prime_will_rise',
terms: 'on',
})
.expect(401);
.expect(400);
// username field should be translated from identifier
expect(res.body.messages?.username?.name).toStrictEqual('AlreadyExistsValidationError');