mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
refactor: move error messages from controller to service
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
f672c5179f
commit
4500caf882
2 changed files with 11 additions and 21 deletions
|
@ -75,25 +75,15 @@ export class AuthController {
|
|||
@RequestUser() user: User,
|
||||
@Body() changePasswordDto: UpdatePasswordDto,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await this.identityService.checkLocalPassword(
|
||||
user,
|
||||
changePasswordDto.currentPassword,
|
||||
);
|
||||
await this.identityService.updateLocalPassword(
|
||||
user,
|
||||
changePasswordDto.newPassword,
|
||||
);
|
||||
return;
|
||||
} catch (e) {
|
||||
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;
|
||||
}
|
||||
await this.identityService.checkLocalPassword(
|
||||
user,
|
||||
changePasswordDto.currentPassword,
|
||||
);
|
||||
await this.identityService.updateLocalPassword(
|
||||
user,
|
||||
changePasswordDto.newPassword,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@UseGuards(LoginEnabledGuard, LocalAuthGuard)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue