From ef60112855237c7fc268abed1a15f067ff9128b4 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Sat, 30 Apr 2022 09:16:46 +1000 Subject: [PATCH 1/2] [PS-74] Fix user authentication state checks (#1464) * Use new authStatus method, clean up account switcher * Update naming * update jslib --- jslib | 2 +- src/app/app.component.ts | 10 +++++++--- .../layout/account-switcher.component.html | 17 ++++++++--------- src/app/layout/account-switcher.component.ts | 19 +++++++------------ src/locales/en/messages.json | 6 ++++++ 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/jslib b/jslib index d7e55465..2e2849b4 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit d7e554653a7e593f8cdaf7e2fe926eb04fb5d5c5 +Subproject commit 2e2849b4def0534f3f72b7a84c3183ab0b1589f2 diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8923eb45..b824b5fe 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -35,6 +35,7 @@ import { SyncService } from "jslib-common/abstractions/sync.service"; import { SystemService } from "jslib-common/abstractions/system.service"; import { TokenService } from "jslib-common/abstractions/token.service"; import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service"; +import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus"; import { CipherType } from "jslib-common/enums/cipherType"; import { MenuUpdateRequest } from "../main/menu/menu.updater"; @@ -330,7 +331,9 @@ export class AppComponent implements OnInit { if (message.userId != null) { await this.stateService.setActiveUser(message.userId); } - const locked = await this.vaultTimeoutService.isLocked(message.userId); + const locked = + (await this.authService.getAuthStatus(message.userId)) === + AuthenticationStatus.Locked; if (locked) { this.messagingService.send("locked", { userId: message.userId }); } else { @@ -436,7 +439,8 @@ export class AppComponent implements OnInit { isAuthenticated: await this.stateService.getIsAuthenticated({ userId: userId, }), - isLocked: await this.vaultTimeoutService.isLocked(userId), + isLocked: + (await this.authService.getAuthStatus(userId)) === AuthenticationStatus.Locked, email: stateAccounts[i].profile.email, userId: stateAccounts[i].profile.userId, }; @@ -591,7 +595,7 @@ export class AppComponent implements OnInit { const keys = Object.keys(accounts); if (keys.length > 0) { for (const userId of keys) { - if (!(await this.vaultTimeoutService.isLocked(userId))) { + if ((await this.authService.getAuthStatus(userId)) === AuthenticationStatus.Unlocked) { return; } } diff --git a/src/app/layout/account-switcher.component.html b/src/app/layout/account-switcher.component.html index a01907f1..0d52b719 100644 --- a/src/app/layout/account-switcher.component.html +++ b/src/app/layout/account-switcher.component.html @@ -53,7 +53,6 @@ diff --git a/src/app/layout/account-switcher.component.ts b/src/app/layout/account-switcher.component.ts index 6fb6c140..1958bed7 100644 --- a/src/app/layout/account-switcher.component.ts +++ b/src/app/layout/account-switcher.component.ts @@ -2,9 +2,9 @@ import { animate, state, style, transition, trigger } from "@angular/animations" import { ConnectedPosition } from "@angular/cdk/overlay"; import { Component, OnInit } from "@angular/core"; +import { AuthService } from "jslib-common/abstractions/auth.service"; import { MessagingService } from "jslib-common/abstractions/messaging.service"; import { StateService } from "jslib-common/abstractions/state.service"; -import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service"; import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus"; import { Utils } from "jslib-common/misc/utils"; import { Account } from "jslib-common/models/domain/account"; @@ -53,6 +53,7 @@ export class AccountSwitcherComponent implements OnInit { accounts: { [userId: string]: SwitcherAccount } = {}; activeAccountEmail: string; serverUrl: string; + authStatus = AuthenticationStatus; overlayPostition: ConnectedPosition[] = [ { originX: "end", @@ -78,22 +79,16 @@ export class AccountSwitcherComponent implements OnInit { constructor( private stateService: StateService, - private vaultTimeoutService: VaultTimeoutService, + private authService: AuthService, private messagingService: MessagingService ) {} async ngOnInit(): Promise { - this.stateService.accounts.subscribe(async (accounts) => { + this.stateService.accounts.subscribe(async (accounts: { [userId: string]: Account }) => { for (const userId in accounts) { - if (userId === (await this.stateService.getUserId())) { - accounts[userId].profile.authenticationStatus = AuthenticationStatus.Active; - } else { - accounts[userId].profile.authenticationStatus = (await this.vaultTimeoutService.isLocked( - userId - )) - ? AuthenticationStatus.Locked - : AuthenticationStatus.Unlocked; - } + accounts[userId].profile.authenticationStatus = await this.authService.getAuthStatus( + userId + ); } this.accounts = await this.createSwitcherAccounts(accounts); diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index af873f0c..f465bcd0 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -1853,6 +1853,12 @@ } } }, + "locked": { + "message": "Locked" + }, + "unlocked": { + "message": "Unlocked" + }, "generator": { "message": "Generator" }, From 0396d682b1be44799ace65e8c3930749e45addbb Mon Sep 17 00:00:00 2001 From: "Patrick H. Lauke" Date: Sat, 30 Apr 2022 15:09:41 +0100 Subject: [PATCH 2/2] Change links to buttons, expose `aria-pressed` for toggles, add `aria-expanded` to send view's "Options" (#1437) * Change links to buttons, expose `aria-pressed` for toggles - also make existing `` type controls keyboard focusable with the addition of `tabindex="0"` * Correctly set aria-pressed now that I have a working build environment, could verify correct way to set this with my limited Angular knowledge * Change more links to buttons, initial style changes * Fix layout of - {{ "cancel" | i18n }} + {{ "cancel" | i18n }} diff --git a/src/app/accounts/lock.component.html b/src/app/accounts/lock.component.html index e503282c..71ac7594 100644 --- a/src/app/accounts/lock.component.html +++ b/src/app/accounts/lock.component.html @@ -30,12 +30,11 @@ />
- +
diff --git a/src/app/accounts/login.component.html b/src/app/accounts/login.component.html index d4495781..bf7830e1 100644 --- a/src/app/accounts/login.component.html +++ b/src/app/accounts/login.component.html @@ -1,7 +1,7 @@
- +
@@ -83,18 +82,22 @@ > - + {{ "createAccount" | i18n }} diff --git a/src/app/accounts/register.component.html b/src/app/accounts/register.component.html index c0c3ce14..4136f5cf 100644 --- a/src/app/accounts/register.component.html +++ b/src/app/accounts/register.component.html @@ -40,12 +40,11 @@ />
- +
@@ -91,12 +90,11 @@ />
- +
@@ -146,7 +144,7 @@ {{ "submit" | i18n }} - {{ "cancel" | i18n }} + {{ "cancel" | i18n }}
diff --git a/src/app/accounts/set-password.component.html b/src/app/accounts/set-password.component.html index d7afcda8..61e99105 100644 --- a/src/app/accounts/set-password.component.html +++ b/src/app/accounts/set-password.component.html @@ -56,12 +56,11 @@ />
- +
@@ -109,12 +108,11 @@ />
- +
diff --git a/src/app/accounts/two-factor-options.component.html b/src/app/accounts/two-factor-options.component.html index 8dd875e9..778d2636 100644 --- a/src/app/accounts/two-factor-options.component.html +++ b/src/app/accounts/two-factor-options.component.html @@ -7,8 +7,8 @@ {{ "twoStepOptions" | i18n }} diff --git a/src/app/accounts/two-factor.component.html b/src/app/accounts/two-factor.component.html index aab55ab2..e2abd0f8 100644 --- a/src/app/accounts/two-factor.component.html +++ b/src/app/accounts/two-factor.component.html @@ -124,22 +124,21 @@ > - {{ "cancel" | i18n }} + {{ "cancel" | i18n }} diff --git a/src/app/accounts/update-temp-password.component.html b/src/app/accounts/update-temp-password.component.html index 26ee4672..084c3217 100644 --- a/src/app/accounts/update-temp-password.component.html +++ b/src/app/accounts/update-temp-password.component.html @@ -36,12 +36,11 @@ />
- +
@@ -84,12 +83,11 @@ />
- +
@@ -120,7 +118,7 @@ {{ "submit" | i18n }} - {{ "logOut" | i18n }} + diff --git a/src/app/components/password-reprompt.component.html b/src/app/components/password-reprompt.component.html index f2805761..078e983b 100644 --- a/src/app/components/password-reprompt.component.html +++ b/src/app/components/password-reprompt.component.html @@ -19,12 +19,11 @@ />
- +
diff --git a/src/app/components/set-pin.component.html b/src/app/components/set-pin.component.html index 538eb0a2..78552942 100644 --- a/src/app/components/set-pin.component.html +++ b/src/app/components/set-pin.component.html @@ -22,9 +22,9 @@ />
- +
diff --git a/src/app/send/add-edit.component.html b/src/app/send/add-edit.component.html index 7a43aacb..a91bfb6c 100644 --- a/src/app/send/add-edit.component.html +++ b/src/app/send/add-edit.component.html @@ -93,21 +93,21 @@
- {{ "options" | i18n }} - + {{ "options" | i18n }} - +
@@ -157,12 +157,11 @@ />
- +
diff --git a/src/app/send/send.component.html b/src/app/send/send.component.html index fc52a836..853debb5 100644 --- a/src/app/send/send.component.html +++ b/src/app/send/send.component.html @@ -5,26 +5,44 @@

{{ "filters" | i18n }}

{{ "types" | i18n }}

@@ -36,20 +54,21 @@
diff --git a/src/app/vault/add-edit-custom-fields.component.html b/src/app/vault/add-edit-custom-fields.component.html index 9f5fc24a..0e5a8f6e 100644 --- a/src/app/vault/add-edit-custom-fields.component.html +++ b/src/app/vault/add-edit-custom-fields.component.html @@ -10,15 +10,14 @@ *ngFor="let f of cipher.fields; let i = index; trackBy: trackByFunction" [ngClass]="{ 'box-content-row-checkbox': f.type === fieldType.Boolean }" > - - +
@@ -78,12 +77,11 @@ class="action-buttons" *ngIf="f.type === fieldType.Hidden && (cipher.viewPassword || f.newField)" > - +
@@ -102,10 +100,10 @@
- +
- - +
- {{ "newUri" | i18n }} - +
@@ -477,9 +476,13 @@
-
{{ "attachments" | i18n }}
-
- +
diff --git a/src/app/vault/ciphers.component.html b/src/app/vault/ciphers.component.html index 1dbbb89c..90a70360 100644 --- a/src/app/vault/ciphers.component.html +++ b/src/app/vault/ciphers.component.html @@ -6,14 +6,15 @@ *ngIf="ciphers.length" > - +
diff --git a/src/app/vault/groupings.component.html b/src/app/vault/groupings.component.html index 276c7f57..148c21d1 100644 --- a/src/app/vault/groupings.component.html +++ b/src/app/vault/groupings.component.html @@ -3,44 +3,86 @@

{{ "filters" | i18n }}

{{ "types" | i18n }}

{{ "loading" | i18n }}

@@ -57,7 +99,13 @@ *ngFor="let f of folders" [ngClass]="{ active: selectedFolder && f.node.id === selectedFolderId }" > - +
- - +
diff --git a/src/app/vault/password-history.component.html b/src/app/vault/password-history.component.html index 8ce5b059..633cee14 100644 --- a/src/app/vault/password-history.component.html +++ b/src/app/vault/password-history.component.html @@ -15,16 +15,15 @@ {{ h.lastUsedDate | date: "medium" }}
- - +
diff --git a/src/app/vault/view-custom-fields.component.html b/src/app/vault/view-custom-fields.component.html index a180885f..d1980048 100644 --- a/src/app/vault/view-custom-fields.component.html +++ b/src/app/vault/view-custom-fields.component.html @@ -35,24 +35,23 @@
diff --git a/src/app/vault/view.component.html b/src/app/vault/view.component.html index 3a2b12ef..df7d590b 100644 --- a/src/app/vault/view.component.html +++ b/src/app/vault/view.component.html @@ -22,16 +22,15 @@ {{ cipher.login.username }}
- - +
@@ -74,31 +73,29 @@ aria-hidden="true" > - - - +
- - +
@@ -157,31 +153,29 @@ {{ cipher.card.number }}
@@ -199,31 +193,29 @@ {{ cipher.card.code }}
@@ -289,27 +281,25 @@ {{ u.hostOrUri }} @@ -334,10 +324,10 @@ {{ "attachments" | i18n }}
- +
@@ -369,15 +359,14 @@
{{ "passwordHistory" | i18n }}: - - +
diff --git a/src/scss/base.scss b/src/scss/base.scss index 4c9445da..70889595 100644 --- a/src/scss/base.scss +++ b/src/scss/base.scss @@ -84,6 +84,9 @@ button { } button { + border: none; + background: transparent; + color: inherit; white-space: nowrap; cursor: pointer; } diff --git a/src/scss/box.scss b/src/scss/box.scss index ddb7bcca..a955617f 100644 --- a/src/scss/box.scss +++ b/src/scss/box.scss @@ -105,9 +105,11 @@ .box-content-row { display: block; + width: 100%; padding: 10px 15px; position: relative; z-index: 1; + text-align: left; &:before { content: ""; @@ -232,7 +234,8 @@ margin-top: 5px; } - > a { + > a, + > button { padding: 8px 8px 8px 4px; margin: 0; @@ -366,7 +369,7 @@ &:not(.box-draggable-row) { .action-buttons .row-btn:last-child { - padding-right: 2px !important; + margin-right: -6px !important; } } diff --git a/src/scss/list.scss b/src/scss/list.scss index fb6ddac3..45288e5e 100644 --- a/src/scss/list.scss +++ b/src/scss/list.scss @@ -1,10 +1,8 @@ @import "variables.scss"; -.list > a { - display: block; +.list > button { padding: 3px 10px; text-decoration: none; - position: relative; user-select: none; z-index: 1; @@ -105,11 +103,14 @@ } } -.list > a.flex-list-item { +.list > button.flex-list-item { display: flex; align-items: center; + width: 100%; + text-align: left; .item-icon { + display: block; margin-left: -5px; margin-right: 4px; @include themify($themes) { @@ -118,7 +119,9 @@ } .item-content { + display: block; .item-title { + display: block; .title-badges { @include themify($themes) { color: themed("mutedColor"); @@ -135,12 +138,12 @@ } .flex-cipher-list-item { - flex-direction: column; - flex-wrap: nowrap; - justify-content: center; - align-items: flex-start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + + > * { + text-align: left; + } } } diff --git a/src/scss/vault.scss b/src/scss/vault.scss index 11623cd2..adef1984 100644 --- a/src/scss/vault.scss +++ b/src/scss/vault.scss @@ -129,7 +129,7 @@ app-root { ul.bwi-ul { // Level 1 li { - > a { + > button { padding-left: 12px; } @@ -137,14 +137,14 @@ app-root { left: -4px; } - &.active > a .bwi-li { + &.active > button .bwi-li { left: 11px; } } // Level 2 ul li { - > a { + > button { padding-left: 23px; } @@ -152,14 +152,14 @@ app-root { left: 7px; } - &.active > a .bwi-li { + &.active > button .bwi-li { left: 22px; } } // Level 3 ul ul li { - > a { + > button { padding-left: 34px; } @@ -167,14 +167,14 @@ app-root { left: 18px; } - &.active > a .bwi-li { + &.active > button .bwi-li { left: 33px; } } // Level 4 ul ul ul li { - > a { + > button { padding-left: 45px; } @@ -182,14 +182,14 @@ app-root { left: 29px; } - &.active > a .bwi-li { + &.active > button .bwi-li { left: 44px; } } // Level 5 ul ul ul ul li { - > a { + > button { padding-left: 56px; } @@ -197,14 +197,14 @@ app-root { left: 40px; } - &.active > a .bwi-li { + &.active > button .bwi-li { left: 55px; } } // Level 6 ul ul ul ul ul li { - > a { + > button { padding-left: 67px; } @@ -212,14 +212,14 @@ app-root { left: 51px; } - &.active > a .bwi-li { + &.active > button .bwi-li { left: 66px; } } // Level 7 ul ul ul ul ul ul li { - > a { + > button { padding-left: 78px; } @@ -227,7 +227,7 @@ app-root { left: 62px; } - &.active > a .bwi-li { + &.active > button .bwi-li { left: 77px; } } @@ -238,10 +238,11 @@ app-root { margin: 0; li { - a { + button { padding: 5px 0; display: flex; align-items: center; + width: 100%; @include themify($themes) { color: themed("textColor");