PM-7392 - Browser Popup app comp - restore done logging out message functionality + add new default logout message
This commit is contained in:
parent
775598f448
commit
89d2d5ec4a
|
@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit } from "@angula
|
||||||
import { NavigationEnd, Router, RouterOutlet } from "@angular/router";
|
import { NavigationEnd, Router, RouterOutlet } from "@angular/router";
|
||||||
import { Subject, takeUntil, firstValueFrom, concatMap, filter, tap } from "rxjs";
|
import { Subject, takeUntil, firstValueFrom, concatMap, filter, tap } from "rxjs";
|
||||||
|
|
||||||
|
import { LogoutReason } from "@bitwarden/auth/common";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
|
@ -10,7 +11,12 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
||||||
import { MessageListener } from "@bitwarden/common/platform/messaging";
|
import { MessageListener } from "@bitwarden/common/platform/messaging";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { DialogService, SimpleDialogOptions, ToastService } from "@bitwarden/components";
|
import {
|
||||||
|
DialogService,
|
||||||
|
SimpleDialogOptions,
|
||||||
|
ToastOptions,
|
||||||
|
ToastService,
|
||||||
|
} from "@bitwarden/components";
|
||||||
|
|
||||||
import { BrowserApi } from "../platform/browser/browser-api";
|
import { BrowserApi } from "../platform/browser/browser-api";
|
||||||
import { BrowserStateService } from "../platform/services/abstractions/browser-state.service";
|
import { BrowserStateService } from "../platform/services/abstractions/browser-state.service";
|
||||||
|
@ -84,6 +90,10 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
tap((msg: any) => {
|
tap((msg: any) => {
|
||||||
if (msg.command === "doneLoggingOut") {
|
if (msg.command === "doneLoggingOut") {
|
||||||
this.authService.logOut(async () => {
|
this.authService.logOut(async () => {
|
||||||
|
if (msg.logoutReason) {
|
||||||
|
await this.displayLogoutReason(msg.logoutReason);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
// 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
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
this.router.navigate(["home"]);
|
this.router.navigate(["home"]);
|
||||||
|
@ -232,4 +242,36 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
this.browserSendStateService.setBrowserSendTypeComponentState(null),
|
this.browserSendStateService.setBrowserSendTypeComponentState(null),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async displayLogoutReason(logoutReason: LogoutReason) {
|
||||||
|
let toastOptions: ToastOptions;
|
||||||
|
switch (logoutReason) {
|
||||||
|
case "invalidSecurityStamp": {
|
||||||
|
toastOptions = {
|
||||||
|
variant: "warning",
|
||||||
|
title: this.i18nService.t("loggedOut"),
|
||||||
|
message: this.i18nService.t("loginExpired"),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "sessionExpired": {
|
||||||
|
toastOptions = {
|
||||||
|
variant: "warning",
|
||||||
|
title: this.i18nService.t("loggedOut"),
|
||||||
|
message: this.i18nService.t("loginExpired"),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
toastOptions = {
|
||||||
|
variant: "warning",
|
||||||
|
title: this.i18nService.t("loggedOut"),
|
||||||
|
message: this.i18nService.t("loggedOutDesc"),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toastService.showToast(toastOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue