Validation: respond with http 400 instead of 401
This commit is contained in:
parent
b28e2b75b7
commit
42da8a68bb
@ -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: () => {
|
||||
|
@ -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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user