mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-30 00:58:45 -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 {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Body,
|
Body,
|
||||||
|
ConflictException,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
|
@ -56,7 +57,7 @@ export class AuthController {
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof AlreadyInDBError) {
|
if (e instanceof AlreadyInDBError) {
|
||||||
throw new BadRequestException(e.message);
|
throw new ConflictException(e.message);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ describe('Auth', () => {
|
||||||
.post('/api/private/auth/local')
|
.post('/api/private/auth/local')
|
||||||
.set('Content-Type', 'application/json')
|
.set('Content-Type', 'application/json')
|
||||||
.send(JSON.stringify(registrationDto))
|
.send(JSON.stringify(registrationDto))
|
||||||
.expect(400);
|
.expect(409);
|
||||||
});
|
});
|
||||||
it('when registration is disabled', async () => {
|
it('when registration is disabled', async () => {
|
||||||
testSetup.configService.get('authConfig').local.enableRegister = false;
|
testSetup.configService.get('authConfig').local.enableRegister = false;
|
||||||
|
|
Loading…
Reference in a new issue