mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
Change error types in checkLocalPassword and updateLocalPassword to InvalidCredentialsError and NoLocalIdentityError
Signed-off-by: Yannick Bungers <git@innay.de>
This commit is contained in:
parent
f39315ea7b
commit
b562a5dac7
4 changed files with 38 additions and 15 deletions
|
@ -17,7 +17,11 @@ import {
|
|||
} from '@nestjs/common';
|
||||
import { Session } from 'express-session';
|
||||
|
||||
import { AlreadyInDBError, NotInDBError } from '../../../errors/errors';
|
||||
import {
|
||||
AlreadyInDBError,
|
||||
InvalidCredentialsError,
|
||||
NoLocalIdentityError,
|
||||
} from '../../../errors/errors';
|
||||
import { IdentityService } from '../../../identity/identity.service';
|
||||
import { LocalAuthGuard } from '../../../identity/local/local.strategy';
|
||||
import { LoginDto } from '../../../identity/local/login.dto';
|
||||
|
@ -80,10 +84,11 @@ export class AuthController {
|
|||
);
|
||||
return;
|
||||
} catch (e) {
|
||||
if (e instanceof NotInDBError) {
|
||||
throw new UnauthorizedException(
|
||||
'Verifying your identity with the current password did not work.',
|
||||
);
|
||||
if (e instanceof InvalidCredentialsError) {
|
||||
throw new UnauthorizedException('Password is not correct');
|
||||
}
|
||||
if (e instanceof NoLocalIdentityError) {
|
||||
throw new BadRequestException('User has no local identity.');
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue