From d26ddb8cb497c3954f11901c2d4c2c467048b375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Tue, 7 Jul 2026 10:58:10 +0200 Subject: [PATCH] fix(frontend/auth): fixed change password form --- .../modules/account/account.component.html | 8 +++- .../app/modules/account/account.component.ts | 45 +++++++++++++------ webapp/src/app/shared/pipes/status.pipe.ts | 2 + 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/webapp/src/app/modules/account/account.component.html b/webapp/src/app/modules/account/account.component.html index da753236..098a8e75 100644 --- a/webapp/src/app/modules/account/account.component.html +++ b/webapp/src/app/modules/account/account.component.html @@ -63,7 +63,13 @@ [formField]="changePasswordForm.showPasswords" >Passwörter anzeigen - diff --git a/webapp/src/app/modules/account/account.component.ts b/webapp/src/app/modules/account/account.component.ts index 647e5a99..651335a0 100644 --- a/webapp/src/app/modules/account/account.component.ts +++ b/webapp/src/app/modules/account/account.component.ts @@ -28,6 +28,7 @@ import { MatButtonModule } from '@angular/material/button'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import { CredentialService } from '../../shared/services/credential.service'; import { MatSnackBar } from '@angular/material/snack-bar'; +import { Router } from '@angular/router'; interface ChangePasswordForm { oldPassword: string; @@ -62,6 +63,7 @@ export class AccountComponent { private readonly _credentialService = inject(CredentialService); private readonly _snackBar = inject(MatSnackBar); + private readonly _router = inject(Router); roles: UserRole[] = []; @@ -143,21 +145,36 @@ export class AccountComponent { const newPassword = field.newPassword().value().trim(); if (!oldPassword || !newPassword) { - return; - } - try { - await this._credentialService.changePassword( - oldPassword, - newPassword, - ); - } catch (error) { - console.error('Error changing password:', error); - this._snackBar.open( - 'Fehler beim Ändern des Passworts. Bitte versuchen Sie es erneut.', - 'OK', - { duration: 7000 }, - ); + return {} as any; } + this._credentialService + .changePassword(oldPassword, newPassword) + .subscribe({ + next: () => { + this._credentialService.refreshAccessToken().subscribe({ + next: () => { + this._router.navigate(['/dashboard']); + }, + error: (error) => { + this._snackBar.open( + 'Fehler beim Aktualisieren des Zugriffstokens. Bitte melden Sie sich erneut an.', + 'OK', + { duration: 7000 }, + ); + }, + }); + }, + error: (error) => { + console.error('Error changing password:', error); + this._snackBar.open( + 'Fehler beim Ändern des Passworts. Bitte versuchen Sie es erneut.', + 'OK', + { duration: 7000 }, + ); + }, + }); + + return {} as any; }, }, }, diff --git a/webapp/src/app/shared/pipes/status.pipe.ts b/webapp/src/app/shared/pipes/status.pipe.ts index 5ba35960..e386fe3a 100644 --- a/webapp/src/app/shared/pipes/status.pipe.ts +++ b/webapp/src/app/shared/pipes/status.pipe.ts @@ -11,6 +11,8 @@ export class StatusPipe implements PipeTransform { return 'Aktiv'; case 'INACTIVE': return 'Inaktiv'; + case 'DELETED': + return 'Gelöscht'; default: return value; }