1
0
mirror of https://github.com/bitwarden/desktop synced 2026-02-14 15:33:30 +00:00
This commit is contained in:
addison
2021-11-10 18:55:19 -05:00
parent d520b88e16
commit 9f73d40f59
9 changed files with 86 additions and 59 deletions

View File

@@ -114,7 +114,7 @@ export class AppComponent implements OnInit {
ngOnInit() {
this.ngZone.runOutsideAngular(() => {
setTimeout(async () => {
await this.updateAppMenu('auth');
await this.updateAppMenu();
}, 1000);
window.onmousemove = () => this.recordActivity();
@@ -131,7 +131,7 @@ export class AppComponent implements OnInit {
case 'loggedIn':
case 'unlocked':
this.notificationsService.updateConnection();
this.updateAppMenu('auth');
this.updateAppMenu();
this.systemService.cancelProcessReload();
break;
case 'loggedOut':
@@ -139,7 +139,7 @@ export class AppComponent implements OnInit {
this.modal.close();
}
this.notificationsService.updateConnection();
this.updateAppMenu('auth');
this.updateAppMenu();
this.systemService.startProcessReload();
await this.systemService.clearPendingClipboard();
break;
@@ -152,14 +152,23 @@ export class AppComponent implements OnInit {
case 'lockVault':
await this.vaultTimeoutService.lock(true, message.userId);
break;
case 'lockAllVaults':
for (const userId in this.stateService.accounts.getValue()) {
if (userId != null) {
await this.vaultTimeoutService.lock(true, userId);
}
}
break;
case 'locked':
if (this.modal != null) {
this.modal.close();
}
this.router.navigate(['lock']);
this.updateAppMenu();
if (message.userId === null || message.userId === await this.stateService.getUserId()) {
this.router.navigate(['lock']);
}
this.notificationsService.updateConnection();
this.updateAppMenu('auth');
this.systemService.startProcessReload();
// this.systemService.startProcessReload();
await this.systemService.clearPendingClipboard();
break;
case 'reloadProcess':
@@ -168,7 +177,7 @@ export class AppComponent implements OnInit {
case 'syncStarted':
break;
case 'syncCompleted':
await this.updateAppMenu('sync');
await this.updateAppMenu();
break;
case 'openSettings':
await this.openModal<SettingsComponent>(SettingsComponent, this.settingsRef);
@@ -332,39 +341,35 @@ export class AppComponent implements OnInit {
});
}
private async updateAppMenu(type: 'auth' | 'sync') {
private async updateAppMenu() {
let data: any;
if (type === 'sync') {
const stateAccounts = this.stateService.accounts?.getValue();
if (stateAccounts == null || Object.keys(stateAccounts).length < 1) {
data = {
accounts: null,
activeUserId: null,
enableChangeMasterPass: false,
}
} else {
const accounts: { [userId: string]: any } = {};
for (const i in stateAccounts) {
if (i != null) {
const userId = stateAccounts[i].userId;
accounts[userId] = {
isAuthenticated: await this.stateService.getIsAuthenticated({
userId: userId,
}),
isLocked: await this.vaultTimeoutService.isLocked(userId),
email: stateAccounts[i].email,
userId: stateAccounts[i].userId,
};
}
}
data = {
accounts: accounts,
activeUserId: await this.stateService.getUserId(),
enableChangeMasterPass: !await this.keyConnectorService.getUsesKeyConnector(),
};
} else {
const stateAccounts = this.stateService.accounts?.getValue();
if (stateAccounts == null || Object.keys(stateAccounts).length < 1) {
data = {
accounts: null,
activeUserId: null,
}
} else {
const accounts: { [userId: string]: any } = {};
for (const i in stateAccounts) {
if (i != null) {
const userId = stateAccounts[i].userId;
accounts[userId] = {
isAuthenticated: await this.stateService.getIsAuthenticated({
userId: userId, storageLocation: StorageLocation.Memory,
}),
isLocked: await this.vaultTimeoutService.isLocked(userId),
email: stateAccounts[i].email,
userId: stateAccounts[i].userId,
};
}
}
data = {
accounts: accounts,
activeUserId: await this.stateService.getUserId(),
};
}
}
this.messagingService.send('updateAppMenu', data);

View File

@@ -7,7 +7,7 @@
<ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]="trigger" [cdkConnectedOverlayOpen]="isOpen" cdkConnectedOverlayMinWidth="250px">
<div class="account-switcher-dropdown" [@transformPanel]="'open'">
<div class="accounts">
<a *ngFor="let a of accounts | keyvalue" class="account" [ngClass]="{'active': a.status == 'active'}"
<a *ngFor="let a of accounts | keyvalue" class="account" [ngClass]="{'active': a.value.authenticationStatus == 'active'}"
href="#" appStopClick (click)="switch(a.value.userId)">
<span class="email">{{a.value.email}}</span>
<span class="server">{{a.value.serverUrl}}</span>

View File

@@ -51,7 +51,7 @@ export class AccountSwitcherComponent implements OnInit {
await this.stateService.setActiveUser(userId);
const locked = await this.vaultTimeoutService.isLocked(userId);
if (locked) {
this.messagingService.send('locked');
this.messagingService.send('locked', { userId: userId });
} else {
this.messagingService.send('unlocked');
this.messagingService.send('syncVault');

View File

@@ -159,7 +159,7 @@ export function initFactory(): Function {
return async () => {
await environmentService.setUrlsFromStorage();
syncService.fullSync(true);
vaultTimeoutService.init(true);
await vaultTimeoutService.init(true);
const locale = await stateService.getLocale();
await i18nService.init(locale);
eventService.init(true);

View File

@@ -1780,5 +1780,8 @@
},
"ssoKeyConnectorUnavailable": {
"message": "Unable to reach the key connector, try again later."
},
"lockAllVaults": {
"message": "Lock All Vaults"
}
}

View File

@@ -104,6 +104,7 @@ export class MenuMain extends BaseMenu {
this.tryUnlockActiveAccountAuthBasedMenuItems(accounts[activeUserId]);
this.lockNow.enabled = true;
this.logOut.enabled = true;
for (const i in accounts) {
if (this.lockNow.submenu.getMenuItemById(`lockNow_${accounts[i].userId}`) == null) {
const options: MenuItemConstructorOptions = {
@@ -113,6 +114,27 @@ export class MenuMain extends BaseMenu {
};
this.lockNow.submenu.insert(0, new MenuItem(options));
}
if (this.logOut.submenu.getMenuItemById(`logOut_${accounts[i].userId}`) == null) {
const options: MenuItemConstructorOptions = {
label: accounts[i].email,
id: `logOut_${accounts[i].userId}`,
click: async () => {
const result = await dialog.showMessageBox(this.windowMain.win, {
title: this.i18nService.t('logOut'),
message: this.i18nService.t('logOut'),
detail: this.i18nService.t('logOutConfirmation'),
buttons: [this.i18nService.t('logOut'), this.i18nService.t('cancel')],
cancelId: 1,
defaultId: 0,
noLink: true,
});
if (result.response === 0) {
this.main.messagingService.send('logout', { userId: accounts[i].userId });
}
},
};
this.logOut.submenu.insert(0, new MenuItem(options));
}
}
}
@@ -424,28 +446,22 @@ export class MenuMain extends BaseMenu {
{
label: this.main.i18nService.t('lockVault'),
id: 'lockNow',
accelerator: 'CmdOrCtrl+L',
submenu: [
// List of vaults
],
},
{
label: this.i18nService.t('logOut'),
label: this.main.i18nService.t('lockAllVaults'),
click: () => this.main.messagingService.send('lockAllVaults'),
id: 'lockNow',
accelerator: 'CmdOrCtrl+L',
},
{
label: this.main.i18nService.t('logOut'),
id: 'logOut',
click: async () => {
const result = await dialog.showMessageBox(this.windowMain.win, {
title: this.i18nService.t('logOut'),
message: this.i18nService.t('logOut'),
detail: this.i18nService.t('logOutConfirmation'),
buttons: [this.i18nService.t('logOut'), this.i18nService.t('cancel')],
cancelId: 1,
defaultId: 0,
noLink: true,
});
if (result.response === 0) {
this.main.messagingService.send('logout');
}
},
submenu: [
// List of vaults
],
},
];

View File

@@ -105,7 +105,7 @@
.account-switcher-dropdown {
@include themify($themes) {
background-color: themed('headerBorderColor');
background-color: themed('accountSwitcherBackgroundColor');
}
margin-right: 5px;
margin-top: 1px; // Fix for border-bottom in header
@@ -154,7 +154,7 @@
}
&.active {
font-weight: 600;
background-color: #ececec;
}
}
}

View File

@@ -8,12 +8,12 @@
@media (min-height: 500px) {
height: calc(100% + 50px);
margin-top: -50px;
padding-bottom: 50px;
}
@media (min-height: 800px) {
height: calc(100% + 300px);
margin-top: -300px;
padding-bottom: 300px;
}
img {

View File

@@ -88,6 +88,7 @@ $themes: (
passwordSpecialColor: #c40800,
calloutBorderColor: $border-color-dark,
calloutBackgroundColor: $background-color,
acccountSwitcherBackgroundColor: $background-color,
),
dark: (
textColor: #ffffff,
@@ -138,6 +139,7 @@ $themes: (
passwordSpecialColor: #ff7c70,
calloutBorderColor: #2f2f2f,
calloutBackgroundColor: #363636,
accountSwitcherBackgroundColor: #2f2f2f,
),
nord: (
textColor: $nord5,
@@ -188,6 +190,7 @@ $themes: (
passwordSpecialColor: $nord12,
calloutBorderColor: $nord1,
calloutBackgroundColor: $nord2,
accountSwitcherBackgroundColor: $nord0,
),
);