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: [ { 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); 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/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/modules/vault-filter/components/organization-filter.component.html b/src/app/modules/vault-filter/components/organization-filter.component.html index 4844237b..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,9 +47,9 @@ @@ -112,9 +112,9 @@ diff --git a/src/app/modules/vault/modules/individual-vault/individual-vault.component.html b/src/app/modules/vault/modules/individual-vault/individual-vault.component.html index ab10f22c..e72ea801 100644 --- a/src/app/modules/vault/modules/individual-vault/individual-vault.component.html +++ b/src/app/modules/vault/modules/individual-vault/individual-vault.component.html @@ -95,7 +95,10 @@

    {{ "premiumUpgradeUnlockFeatures" | i18n }}

    - + {{ "goPremium" | i18n }}
    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/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(); }); } diff --git a/src/app/oss-routing.module.ts b/src/app/oss-routing.module.ts index 0eea2fd3..77547813 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: [ @@ -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({ diff --git a/src/app/settings/change-password.component.ts b/src/app/settings/change-password.component.ts index 577c66b0..37246a84 100644 --- a/src/app/settings/change-password.component.ts +++ b/src/app/settings/change-password.component.ts @@ -68,6 +68,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent { if (await this.keyConnectorService.getUsesKeyConnector()) { this.router.navigate(["/settings/security/two-factor"]); } + await super.ngOnInit(); } async rotateEncKeyClicked() { 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 @@ -