Skip to content

Commit

Permalink
feat(auth): [PM-15945] Add logout option to TDE approval page (#12445)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rr-bw authored Dec 17, 2024
1 parent c3f58b2 commit ac13cf7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@
>
{{ "requestAdminApproval" | i18n }}
</button>

<button type="button" bitButton bitFormButton block (click)="logOut()">
{{ "logOut" | i18n }}
</button>
</div>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
AsyncActionsModule,
ButtonModule,
CheckboxModule,
DialogService,
FormFieldModule,
ToastService,
TypographyModule,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 });
}
}
}

0 comments on commit ac13cf7

Please sign in to comment.