2021-08-05 16:56:17 +02:00
|
|
|
import { Component } from "@angular/core";
|
2024-01-02 22:55:42 +01:00
|
|
|
import { firstValueFrom } from "rxjs";
|
2021-08-05 16:56:17 +02:00
|
|
|
|
2023-02-06 22:53:37 +01:00
|
|
|
import { UpdateTempPasswordComponent as BaseUpdateTempPasswordComponent } from "@bitwarden/angular/auth/components/update-temp-password.component";
|
2021-08-05 16:56:17 +02:00
|
|
|
|
2024-01-02 22:55:42 +01:00
|
|
|
import { postLogoutMessageListener$ } from "./utils/post-logout-message-listener";
|
|
|
|
|
2021-08-05 16:56:17 +02:00
|
|
|
@Component({
|
|
|
|
selector: "app-update-temp-password",
|
|
|
|
templateUrl: "update-temp-password.component.html",
|
|
|
|
})
|
2024-01-02 22:55:42 +01:00
|
|
|
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") {
|
2024-02-02 21:13:37 +01:00
|
|
|
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
2024-01-02 22:55:42 +01:00
|
|
|
this.router.navigate(["/"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|