mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-30 01:08:48 -05:00
AuthController: Return 409 Conflict when user already exists
The previously used HTTP error 400 'Bad Request' is not really applicable here, as the client did not send a malformed message. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
3560d82c44
commit
5a16047f50
2 changed files with 3 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
import {
|
||||
BadRequestException,
|
||||
Body,
|
||||
ConflictException,
|
||||
Controller,
|
||||
Delete,
|
||||
NotFoundException,
|
||||
|
@ -56,7 +57,7 @@ export class AuthController {
|
|||
return;
|
||||
} catch (e) {
|
||||
if (e instanceof AlreadyInDBError) {
|
||||
throw new BadRequestException(e.message);
|
||||
throw new ConflictException(e.message);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ describe('Auth', () => {
|
|||
.post('/api/private/auth/local')
|
||||
.set('Content-Type', 'application/json')
|
||||
.send(JSON.stringify(registrationDto))
|
||||
.expect(400);
|
||||
.expect(409);
|
||||
});
|
||||
it('when registration is disabled', async () => {
|
||||
testSetup.configService.get('authConfig').local.enableRegister = false;
|
||||
|
|
Loading…
Reference in a new issue