fix(frontend/auth): fixed change password form
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -63,7 +63,13 @@
|
||||
[formField]="changePasswordForm.showPasswords"
|
||||
>Passwörter anzeigen</mat-slide-toggle
|
||||
>
|
||||
<button mat-raised-button color="primary" type="submit">
|
||||
<button
|
||||
mat-raised-button
|
||||
color="primary"
|
||||
type="submit"
|
||||
[disabled]="
|
||||
changePasswordForm().invalid() || changePasswordForm().submitting()
|
||||
">
|
||||
Passwort ändern
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -11,6 +11,8 @@ export class StatusPipe implements PipeTransform {
|
||||
return 'Aktiv';
|
||||
case 'INACTIVE':
|
||||
return 'Inaktiv';
|
||||
case 'DELETED':
|
||||
return 'Gelöscht';
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user