Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import { ChangeDetectionStrategy, Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AccountFacade } from 'ish-core/facades/account.facade';
import { HttpError } from 'ish-core/models/http-error/http-error.model';
import { whenTruthy } from 'ish-core/utils/operators';
/**
* The Update Password Component handles the interaction for updating a password via password reminder email link.
* See also {@link UpdatePasswordFormComponent}.
*/
@Component({
selector: 'ish-update-password',
templateUrl: './update-password.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class UpdatePasswordComponent implements OnInit {
error$: Observable<HttpError>;
loading$: Observable<boolean>;
// visible-for-testing
userID: string;
// visible-for-testing
secureCode: string;
private destroyRef = inject(DestroyRef);
constructor(private accountFacade: AccountFacade, private router: Router, private route: ActivatedRoute) {}
ngOnInit(): void {
this.error$ = this.accountFacade.passwordReminderError$;
this.loading$ = this.accountFacade.userLoading$;
this.accountFacade.resetPasswordReminder();
this.route.queryParams
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((params: { uid: string; Hash: string }) => {
this.userID = params.uid;
this.secureCode = params.Hash;
});
this.accountFacade.passwordReminderSuccess$
.pipe(whenTruthy(), takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.router.navigate(['/login'], { queryParams: { forcePageView: true, returnUrl: '/account' } });
});
}
requestPasswordChange(data: { password: string }) {
this.accountFacade.requestPasswordReminderUpdate({ ...data, userID: this.userID, secureCode: this.secureCode });
}
}
|