1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

[SM-487] Fix lock and logout (#4683)

This commit is contained in:
Oscar Hinton
2023-02-14 11:26:20 +01:00
committed by GitHub
parent 4438ab9e3a
commit c3dfb7735f
12 changed files with 23 additions and 11 deletions

View File

@@ -0,0 +1,57 @@
import { Component, Input } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { combineLatest, map, Observable } from "rxjs";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { AccountProfile } from "@bitwarden/common/models/domain/account";
@Component({
selector: "sm-header",
templateUrl: "./header.component.html",
})
export class HeaderComponent {
/**
* Custom title that overrides the route data `titleId`
*/
@Input() title: string;
/**
* Icon to show before the title
*/
@Input() icon: string;
protected routeData$: Observable<{ titleId: string }>;
protected account$: Observable<AccountProfile>;
constructor(
private route: ActivatedRoute,
private stateService: StateService,
private messagingService: MessagingService
) {
this.routeData$ = this.route.data.pipe(
map((params) => {
return {
titleId: params.titleId,
};
})
);
this.account$ = combineLatest([
this.stateService.activeAccount$,
this.stateService.accounts$,
]).pipe(
map(([activeAccount, accounts]) => {
return accounts[activeAccount]?.profile;
})
);
}
protected lock() {
this.messagingService.send("lockVault");
}
protected logout() {
this.messagingService.send("logout");
}
}