1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-23 16:38:45 +01:00

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
This commit is contained in:
rr-bw 2024-12-17 12:48:37 -08:00 committed by GitHub
parent c3f58b2e70
commit ac13cf7ce6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -56,5 +56,9 @@
> >
{{ "requestAdminApproval" | i18n }} {{ "requestAdminApproval" | i18n }}
</button> </button>
<button type="button" bitButton bitFormButton block (click)="logOut()">
{{ "logOut" | i18n }}
</button>
</div> </div>
</ng-container> </ng-container>

View File

@ -30,6 +30,7 @@ import {
AsyncActionsModule, AsyncActionsModule,
ButtonModule, ButtonModule,
CheckboxModule, CheckboxModule,
DialogService,
FormFieldModule, FormFieldModule,
ToastService, ToastService,
TypographyModule, TypographyModule,
@ -90,6 +91,7 @@ export class LoginDecryptionOptionsComponent implements OnInit {
private apiService: ApiService, private apiService: ApiService,
private destroyRef: DestroyRef, private destroyRef: DestroyRef,
private deviceTrustService: DeviceTrustServiceAbstraction, private deviceTrustService: DeviceTrustServiceAbstraction,
private dialogService: DialogService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private i18nService: I18nService, private i18nService: I18nService,
private keyService: KeyService, private keyService: KeyService,
@ -298,4 +300,18 @@ export class LoginDecryptionOptionsComponent implements OnInit {
this.loginEmailService.setLoginEmail(this.email); this.loginEmailService.setLoginEmail(this.email);
await this.router.navigate(["/admin-approval-requested"]); 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 });
}
}
} }