From ac13cf7ce6fb23e1a81ead38008e4011e5217c5b Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:48:37 -0800 Subject: [PATCH] feat(auth): [PM-15945] Add logout option to TDE approval page (#12445) This PR adds a logout option to the TDE approval screen. A TDE user on this page cannot use the "Back" button or click the Bitwarden logo to navigate back to `/` because the user is currently authenticated, which means that navigating to the `/` route would activate the `redirectGuard` and simply route the user back to `/login-initiated`. So we must log the user out first before routing. Feature Flags: `UnauthenticatedExtensionUIRefresh` ON --- .../login-decryption-options.component.html | 4 ++++ .../login-decryption-options.component.ts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.html b/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.html index cb340f646f..b3d218389b 100644 --- a/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.html +++ b/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.html @@ -56,5 +56,9 @@ > {{ "requestAdminApproval" | i18n }} + + diff --git a/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.ts b/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.ts index 070debf220..5600077c36 100644 --- a/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.ts +++ b/libs/auth/src/angular/login-decryption-options/login-decryption-options.component.ts @@ -30,6 +30,7 @@ import { AsyncActionsModule, ButtonModule, CheckboxModule, + DialogService, FormFieldModule, ToastService, TypographyModule, @@ -90,6 +91,7 @@ export class LoginDecryptionOptionsComponent implements OnInit { private apiService: ApiService, private destroyRef: DestroyRef, private deviceTrustService: DeviceTrustServiceAbstraction, + private dialogService: DialogService, private formBuilder: FormBuilder, private i18nService: I18nService, private keyService: KeyService, @@ -298,4 +300,18 @@ export class LoginDecryptionOptionsComponent implements OnInit { this.loginEmailService.setLoginEmail(this.email); await this.router.navigate(["/admin-approval-requested"]); } + + async logOut() { + const confirmed = await this.dialogService.openSimpleDialog({ + title: { key: "logOut" }, + content: { key: "logOutConfirmation" }, + acceptButtonText: { key: "logOut" }, + type: "warning", + }); + + const userId = (await firstValueFrom(this.accountService.activeAccount$))?.id; + if (confirmed) { + this.messagingService.send("logout", { userId: userId }); + } + } }