Route on switchAccountFinish Message (#7422)

This commit is contained in:
Justin Baur 2024-01-02 16:55:42 -05:00 committed by GitHub
parent fb0e8fc2ff
commit f2eea12b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -1,9 +1,27 @@
import { Component } from "@angular/core";
import { firstValueFrom } from "rxjs";
import { UpdateTempPasswordComponent as BaseUpdateTempPasswordComponent } from "@bitwarden/angular/auth/components/update-temp-password.component";
import { postLogoutMessageListener$ } from "./utils/post-logout-message-listener";
@Component({
selector: "app-update-temp-password",
templateUrl: "update-temp-password.component.html",
})
export class UpdateTempPasswordComponent extends BaseUpdateTempPasswordComponent {}
export class UpdateTempPasswordComponent extends BaseUpdateTempPasswordComponent {
onSuccessfulChangePassword: () => Promise<void> = this.doOnSuccessfulChangePassword.bind(this);
private async doOnSuccessfulChangePassword() {
// start listening for "switchAccountFinish" or "doneLoggingOut"
const messagePromise = firstValueFrom(postLogoutMessageListener$);
this.messagingService.send("logout");
// wait for messages
const command = await messagePromise;
// doneLoggingOut already has a message handler that will navigate us
if (command === "switchAccountFinish") {
this.router.navigate(["/"]);
}
}
}

View File

@ -54,7 +54,7 @@ export class UpdateTempPasswordComponent extends BaseChangePasswordComponent {
private syncService: SyncService,
private logService: LogService,
private userVerificationService: UserVerificationService,
private router: Router,
protected router: Router,
dialogService: DialogService,
) {
super(