1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-18 15:47:57 +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 }}
</button>
<button type="button" bitButton bitFormButton block (click)="logOut()">
{{ "logOut" | i18n }}
</button>
</div>
</ng-container>

View File

@ -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 });
}
}
}