From dc2078ae5888860737fdc78de8e5e9a2f1d74566 Mon Sep 17 00:00:00 2001 From: Jake Fink Date: Wed, 11 May 2022 11:13:42 -0400 Subject: [PATCH 01/11] add better error handling to tax call (#1666) --- src/app/settings/tax-info.component.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/settings/tax-info.component.ts b/src/app/settings/tax-info.component.ts index 0f7ff992..f36feadd 100644 --- a/src/app/settings/tax-info.component.ts +++ b/src/app/settings/tax-info.component.ts @@ -73,10 +73,14 @@ export class TaxInfoComponent { this.logService.error(e); } } else { - const taxInfo = await this.apiService.getTaxInfo(); - if (taxInfo) { - this.taxInfo.postalCode = taxInfo.postalCode; - this.taxInfo.country = taxInfo.country || "US"; + try { + const taxInfo = await this.apiService.getTaxInfo(); + if (taxInfo) { + this.taxInfo.postalCode = taxInfo.postalCode; + this.taxInfo.country = taxInfo.country || "US"; + } + } catch (e) { + this.logService.error(e); } } this.pristine = Object.assign({}, this.taxInfo); @@ -86,9 +90,16 @@ export class TaxInfoComponent { } }); - const taxRates = await this.apiService.getTaxRates(); - this.taxRates = taxRates.data; - this.loading = false; + try { + const taxRates = await this.apiService.getTaxRates(); + if (taxRates) { + this.taxRates = taxRates.data; + } + } catch (e) { + this.logService.error(e); + } finally { + this.loading = false; + } } get taxRate() { From ccf0d64a7ba269aa4fda8bf986625a25d4a9687d Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Wed, 11 May 2022 13:32:42 -0400 Subject: [PATCH 02/11] Use correct localization string (#1665) --- .../components/organization-filter.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/modules/vault-filter/components/organization-filter.component.html b/src/app/modules/vault-filter/components/organization-filter.component.html index 4844237b..90c28359 100644 --- a/src/app/modules/vault-filter/components/organization-filter.component.html +++ b/src/app/modules/vault-filter/components/organization-filter.component.html @@ -49,7 +49,7 @@ href="#" routerLink="/settings/create-organization" class="text-muted ml-auto create-organization-link" - appA11yTitle="{{ 'addOrganization' | i18n }}" + appA11yTitle="{{ 'newOrganization' | i18n }}" > @@ -114,7 +114,7 @@ href="#" routerLink="/settings/create-organization" class="text-muted ml-auto create-organization-link" - appA11yTitle="{{ 'addOrganization' | i18n }}" + appA11yTitle="{{ 'newOrganization' | i18n }}" > From 1dc95026765e56fe1e81597c76332a150b5045d4 Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Wed, 11 May 2022 14:10:02 -0400 Subject: [PATCH 03/11] [fix] Update the navbar when creating an organization for the first time (#1668) --- src/app/layouts/navbar.component.ts | 25 ++++++++++++++++--- .../settings/organization-plans.component.ts | 5 +++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/app/layouts/navbar.component.ts b/src/app/layouts/navbar.component.ts index 41585ef4..d93ec65d 100644 --- a/src/app/layouts/navbar.component.ts +++ b/src/app/layouts/navbar.component.ts @@ -1,5 +1,6 @@ -import { Component, OnInit } from "@angular/core"; +import { Component, NgZone, OnInit } from "@angular/core"; +import { BroadcasterService } from "jslib-common/abstractions/broadcaster.service"; import { I18nService } from "jslib-common/abstractions/i18n.service"; import { MessagingService } from "jslib-common/abstractions/messaging.service"; import { OrganizationService } from "jslib-common/abstractions/organization.service"; @@ -31,7 +32,9 @@ export class NavbarComponent implements OnInit { private providerService: ProviderService, private syncService: SyncService, private organizationService: OrganizationService, - private i18nService: I18nService + private i18nService: I18nService, + private broadcasterService: BroadcasterService, + private ngZone: NgZone ) { this.selfHosted = this.platformUtilsService.isSelfHost(); } @@ -49,8 +52,24 @@ export class NavbarComponent implements OnInit { } this.providers = await this.providerService.getAll(); + this.organizations = await this.buildOrganizations(); + + this.broadcasterService.subscribe(this.constructor.name, async (message: any) => { + this.ngZone.run(async () => { + switch (message.command) { + case "organizationCreated": + if (this.organizations.length < 1) { + this.organizations = await this.buildOrganizations(); + } + break; + } + }); + }); + } + + async buildOrganizations() { const allOrgs = await this.organizationService.getAll(); - this.organizations = allOrgs + return allOrgs .filter((org) => OrgNavigationPermissionsService.canAccessAdmin(org)) .sort(Utils.getSortFunction(this.i18nService, "name")); } diff --git a/src/app/settings/organization-plans.component.ts b/src/app/settings/organization-plans.component.ts index 7096aef1..73da459e 100644 --- a/src/app/settings/organization-plans.component.ts +++ b/src/app/settings/organization-plans.component.ts @@ -5,6 +5,7 @@ import { ApiService } from "jslib-common/abstractions/api.service"; import { CryptoService } from "jslib-common/abstractions/crypto.service"; import { I18nService } from "jslib-common/abstractions/i18n.service"; import { LogService } from "jslib-common/abstractions/log.service"; +import { MessagingService } from "jslib-common/abstractions/messaging.service"; import { OrganizationService } from "jslib-common/abstractions/organization.service"; import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; import { PolicyService } from "jslib-common/abstractions/policy.service"; @@ -68,7 +69,8 @@ export class OrganizationPlansComponent implements OnInit { private syncService: SyncService, private policyService: PolicyService, private organizationService: OrganizationService, - private logService: LogService + private logService: LogService, + private messagingService: MessagingService ) { this.selfHosted = platformUtilsService.isSelfHost(); } @@ -298,6 +300,7 @@ export class OrganizationPlansComponent implements OnInit { this.formPromise = doSubmit(); const organizationId = await this.formPromise; this.onSuccess.emit({ organizationId: organizationId }); + this.messagingService.send("organizationCreated", organizationId); } catch (e) { this.logService.error(e); } From f5245a280e1cab5bae613d35e5aacf33983d173e Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Wed, 11 May 2022 15:39:39 -0400 Subject: [PATCH 04/11] [bug:euvr] Create Organization Updates (#1664) --- src/app/accounts/login.component.ts | 2 +- src/app/accounts/register.component.ts | 2 +- .../organization-switcher.component.html | 2 +- .../components/organization-filter.component.html | 6 +++--- src/app/oss-routing.module.ts | 10 +++++----- .../settings/create-organization.component.html | 14 ++++++++++---- src/app/vault/share.component.html | 2 +- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/app/accounts/login.component.ts b/src/app/accounts/login.component.ts index 21a1f6d0..524137a6 100644 --- a/src/app/accounts/login.component.ts +++ b/src/app/accounts/login.component.ts @@ -74,7 +74,7 @@ export class LoginComponent extends BaseLoginComponent { if (qParams.premium != null) { this.routerService.setPreviousUrl("/settings/premium"); } else if (qParams.org != null) { - const route = this.router.createUrlTree(["settings/create-organization"], { + const route = this.router.createUrlTree(["create-organization"], { queryParams: { plan: qParams.org }, }); this.routerService.setPreviousUrl(route.toString()); diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts index fd2f3b56..542bb8e3 100644 --- a/src/app/accounts/register.component.ts +++ b/src/app/accounts/register.component.ts @@ -71,7 +71,7 @@ export class RegisterComponent extends BaseRegisterComponent { } else if (qParams.org != null) { this.showCreateOrgMessage = true; this.referenceData.flow = qParams.org; - const route = this.router.createUrlTree(["settings/create-organization"], { + const route = this.router.createUrlTree(["create-organization"], { queryParams: { plan: qParams.org }, }); this.routerService.setPreviousUrl(route.toString()); diff --git a/src/app/components/organization-switcher.component.html b/src/app/components/organization-switcher.component.html index 69bf5e59..7975fd9e 100644 --- a/src/app/components/organization-switcher.component.html +++ b/src/app/components/organization-switcher.component.html @@ -58,7 +58,7 @@
  • - + {{ "newOrganization" | i18n }} diff --git a/src/app/modules/vault-filter/components/organization-filter.component.html b/src/app/modules/vault-filter/components/organization-filter.component.html index 90c28359..23e3508e 100644 --- a/src/app/modules/vault-filter/components/organization-filter.component.html +++ b/src/app/modules/vault-filter/components/organization-filter.component.html @@ -12,7 +12,7 @@
  • - + {{ "newOrganization" | i18n }} @@ -47,7 +47,7 @@ @@ -112,7 +112,7 @@ diff --git a/src/app/oss-routing.module.ts b/src/app/oss-routing.module.ts index 0eea2fd3..72faa67b 100644 --- a/src/app/oss-routing.module.ts +++ b/src/app/oss-routing.module.ts @@ -155,6 +155,11 @@ const routes: Routes = [ .IndividualVaultModule, }, { path: "sends", component: SendComponent, data: { title: "Send" } }, + { + path: "create-organization", + component: CreateOrganizationComponent, + data: { titleId: "newOrganization" }, + }, { path: "settings", component: SettingsComponent, @@ -181,11 +186,6 @@ const routes: Routes = [ loadChildren: async () => (await import("./settings/subscription-routing.module")).SubscriptionRoutingModule, }, - { - path: "create-organization", - component: CreateOrganizationComponent, - data: { titleId: "newOrganization" }, - }, { path: "emergency-access", children: [ diff --git a/src/app/settings/create-organization.component.html b/src/app/settings/create-organization.component.html index 815442fe..f5b4219a 100644 --- a/src/app/settings/create-organization.component.html +++ b/src/app/settings/create-organization.component.html @@ -1,5 +1,11 @@ - From 74bdfe260222755368647a9ee401c089f3de502e Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Thu, 12 May 2022 09:12:02 +1000 Subject: [PATCH 07/11] Fix permission checking when accessing manage SSO (#1663) --- .../src/app/organizations/organizations-routing.module.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitwarden_license/src/app/organizations/organizations-routing.module.ts b/bitwarden_license/src/app/organizations/organizations-routing.module.ts index 7ce7f56c..c300da14 100644 --- a/bitwarden_license/src/app/organizations/organizations-routing.module.ts +++ b/bitwarden_license/src/app/organizations/organizations-routing.module.ts @@ -22,9 +22,9 @@ const routes: Routes = [ component: ManageComponent, canActivate: [PermissionsGuard], data: { - permissions: [ - NavigationPermissionsService.getPermissions("manage").concat(Permissions.ManageSso), - ], + permissions: NavigationPermissionsService.getPermissions("manage").concat( + Permissions.ManageSso + ), }, children: [ { From e3e7fce70a48fc2e9589e45cc662657bfcae503c Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Thu, 12 May 2022 08:43:27 -0400 Subject: [PATCH 08/11] [bug:euvr] Self-hosted instance hiding subscription nav item (#1669) --- src/app/settings/settings.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index 8b806ab6..9756ba41 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -54,7 +54,11 @@ export class SettingsComponent implements OnInit, OnDestroy { this.premium = await this.tokenService.getPremium(); this.hasFamilySponsorshipAvailable = await this.organizationService.canManageSponsorships(); const hasPremiumFromOrg = await this.stateService.getCanAccessPremium(); - const billing = await this.apiService.getUserBillingHistory(); - this.hideSubscription = !this.premium && hasPremiumFromOrg && billing.hasNoHistory; + let billing = null; + if (!this.selfHosted) { + billing = await this.apiService.getUserBillingHistory(); + } + this.hideSubscription = + !this.premium && hasPremiumFromOrg && (this.selfHosted || billing?.hasNoHistory); } } From 3367736c7e18992748853e4c57350143ca98dd13 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 12 May 2022 15:47:18 +0200 Subject: [PATCH 09/11] [SG-267] Exposed passwords report: console error (#1671) --- .../tools/exposed-passwords-report.component.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/organizations/tools/exposed-passwords-report.component.ts b/src/app/organizations/tools/exposed-passwords-report.component.ts index 1a860864..e3b8f552 100644 --- a/src/app/organizations/tools/exposed-passwords-report.component.ts +++ b/src/app/organizations/tools/exposed-passwords-report.component.ts @@ -14,7 +14,7 @@ import { CipherView } from "jslib-common/models/view/cipherView"; import { ExposedPasswordsReportComponent as BaseExposedPasswordsReportComponent } from "../../reports/exposed-passwords-report.component"; @Component({ - selector: "app-exposed-passwords-report", + selector: "app-org-exposed-passwords-report", templateUrl: "../../reports/exposed-passwords-report.component.html", }) export class ExposedPasswordsReportComponent extends BaseExposedPasswordsReportComponent { @@ -41,12 +41,10 @@ export class ExposedPasswordsReportComponent extends BaseExposedPasswordsReportC } ngOnInit() { - const dynamicSuper = Object.getPrototypeOf(this.constructor.prototype); this.route.parent.parent.params.subscribe(async (params) => { this.organization = await this.organizationService.get(params.organizationId); this.manageableCiphers = await this.cipherService.getAll(); - // TODO: We should do something about this, calling super in an async function is bad - dynamicSuper.ngOnInit(); + await this.checkAccess(); }); } From f4f3e8c5744c07e0bf50c30afb6dac1c6e51c962 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 12 May 2022 16:21:50 +0200 Subject: [PATCH 10/11] [SG-279] Fix unlock button not working after logging in through SSO (#1672) --- src/app/accounts/lock.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index 4b8a0d4b..79148100 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -55,7 +55,7 @@ export class LockComponent extends BaseLockComponent { await super.ngOnInit(); this.onSuccessfulSubmit = async () => { const previousUrl = this.routerService.getPreviousUrl(); - if (previousUrl !== "/" && previousUrl.indexOf("lock") === -1) { + if (previousUrl && previousUrl !== "/" && previousUrl.indexOf("lock") === -1) { this.successRoute = previousUrl; } this.router.navigateByUrl(this.successRoute); From 888892b3e7afe9a93e2ee76dae23cc8db34f0d88 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Fri, 13 May 2022 08:31:30 +1000 Subject: [PATCH 11/11] Revert accidental cnesting of org routes (#1670) --- .../layouts/organization-layout.component.html | 2 ++ src/app/oss-routing.module.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/organizations/layouts/organization-layout.component.html b/src/app/organizations/layouts/organization-layout.component.html index cb0e6bba..3834635e 100644 --- a/src/app/organizations/layouts/organization-layout.component.html +++ b/src/app/organizations/layouts/organization-layout.component.html @@ -1,3 +1,4 @@ +
    @@ -35,3 +36,4 @@
    + diff --git a/src/app/oss-routing.module.ts b/src/app/oss-routing.module.ts index 72faa67b..77547813 100644 --- a/src/app/oss-routing.module.ts +++ b/src/app/oss-routing.module.ts @@ -229,15 +229,15 @@ const routes: Routes = [ (await import("./reports/reports-routing.module")).ReportsRoutingModule, }, { path: "setup/families-for-enterprise", component: FamiliesForEnterpriseSetupComponent }, - { - path: "organizations", - loadChildren: () => - import("./organizations/organization-routing.module").then( - (m) => m.OrganizationsRoutingModule - ), - }, ], }, + { + path: "organizations", + loadChildren: () => + import("./organizations/organization-routing.module").then( + (m) => m.OrganizationsRoutingModule + ), + }, ]; @NgModule({