[AC-1012] Hide link to 2FA policy for Teams orgs (#6154)

- Also cleanup eslint warnings
This commit is contained in:
Shane Melton 2023-09-07 08:06:22 -07:00 committed by GitHub
parent d172dfe2f6
commit 615248e04f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 21 deletions

View File

@ -1,8 +1,11 @@
import { Component } from "@angular/core"; import { Component } from "@angular/core";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { concatMap, takeUntil } from "rxjs";
import { tap } from "rxjs/operators";
import { ModalService } from "@bitwarden/angular/services/modal.service"; import { ModalService } from "@bitwarden/angular/services/modal.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type"; import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
@ -24,17 +27,23 @@ export class TwoFactorSetupComponent extends BaseTwoFactorSetupComponent {
messagingService: MessagingService, messagingService: MessagingService,
policyService: PolicyService, policyService: PolicyService,
private route: ActivatedRoute, private route: ActivatedRoute,
stateService: StateService stateService: StateService,
private organizationService: OrganizationService
) { ) {
super(apiService, modalService, messagingService, policyService, stateService); super(apiService, modalService, messagingService, policyService, stateService);
} }
async ngOnInit() { async ngOnInit() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe this.route.params
this.route.parent.parent.params.subscribe(async (params) => { .pipe(
this.organizationId = params.organizationId; tap((params) => {
await super.ngOnInit(); this.organizationId = params.organizationId;
}); this.organization = this.organizationService.get(this.organizationId);
}),
concatMap(async () => await super.ngOnInit()),
takeUntil(this.destroy$)
)
.subscribe();
} }
async manage(type: TwoFactorProviderType) { async manage(type: TwoFactorProviderType) {
@ -43,8 +52,7 @@ export class TwoFactorSetupComponent extends BaseTwoFactorSetupComponent {
const duoComp = await this.openModal(this.duoModalRef, TwoFactorDuoComponent); const duoComp = await this.openModal(this.duoModalRef, TwoFactorDuoComponent);
duoComp.type = TwoFactorProviderType.OrganizationDuo; duoComp.type = TwoFactorProviderType.OrganizationDuo;
duoComp.organizationId = this.organizationId; duoComp.organizationId = this.organizationId;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil duoComp.onUpdated.pipe(takeUntil(this.destroy$)).subscribe((enabled: boolean) => {
duoComp.onUpdated.subscribe((enabled: boolean) => {
this.updateStatus(enabled, TwoFactorProviderType.OrganizationDuo); this.updateStatus(enabled, TwoFactorProviderType.OrganizationDuo);
}); });
break; break;

View File

@ -1,16 +1,25 @@
<div [ngClass]="tabbedHeader ? 'tabbed-header' : 'page-header'"> <div [ngClass]="tabbedHeader ? 'tabbed-header' : 'page-header'">
<h1 *ngIf="!organizationId">{{ "twoStepLogin" | i18n }}</h1> <h1 *ngIf="!organizationId || !isEnterpriseOrg">{{ "twoStepLogin" | i18n }}</h1>
<h1 *ngIf="organizationId">{{ "twoStepLoginEnforcement" | i18n }}</h1> <h1 *ngIf="organizationId && isEnterpriseOrg">{{ "twoStepLoginEnforcement" | i18n }}</h1>
</div> </div>
<p *ngIf="!organizationId">{{ "twoStepLoginDesc" | i18n }}</p> <p *ngIf="!organizationId">{{ "twoStepLoginDesc" | i18n }}</p>
<ng-container *ngIf="organizationId"> <ng-container *ngIf="organizationId">
<p> <p>
{{ "twoStepLoginOrganizationDescStart" | i18n }} <ng-container *ngIf="isEnterpriseOrg; else teamsDescription">
<a routerLink="../policies">{{ "twoStepLoginPolicy" | i18n }}.</a> {{ "twoStepLoginEnterpriseDescStart" | i18n }}
<br /> <a routerLink="../policies">{{ "twoStepLoginPolicy" | i18n }}.</a>
{{ "twoStepLoginOrganizationDuoDesc" | i18n }} <br />
{{ "twoStepLoginOrganizationDuoDesc" | i18n }}
<br />
<br />
<p>{{ "twoStepLoginOrganizationSsoDesc" | i18n }}</p>
</ng-container>
<ng-template #teamsDescription>
{{ "twoStepLoginTeamsDesc" | i18n }}
<br />
{{ "twoStepLoginOrganizationDuoDesc" | i18n }}
</ng-template>
</p> </p>
<p>{{ "twoStepLoginOrganizationSsoDesc" | i18n }}</p>
</ng-container> </ng-container>
<bit-callout type="warning" *ngIf="!organizationId"> <bit-callout type="warning" *ngIf="!organizationId">
<p>{{ "twoStepLoginRecoveryWarning" | i18n }}</p> <p>{{ "twoStepLoginRecoveryWarning" | i18n }}</p>

View File

@ -6,8 +6,10 @@ import { ModalService } from "@bitwarden/angular/services/modal.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { PolicyType } from "@bitwarden/common/admin-console/enums";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type"; import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type";
import { TwoFactorProviders } from "@bitwarden/common/auth/services/two-factor.service"; import { TwoFactorProviders } from "@bitwarden/common/auth/services/two-factor.service";
import { ProductType } from "@bitwarden/common/enums";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
@ -36,6 +38,7 @@ export class TwoFactorSetupComponent implements OnInit, OnDestroy {
webAuthnModalRef: ViewContainerRef; webAuthnModalRef: ViewContainerRef;
organizationId: string; organizationId: string;
organization: Organization;
providers: any[] = []; providers: any[] = [];
canAccessPremium: boolean; canAccessPremium: boolean;
showPolicyWarning = false; showPolicyWarning = false;
@ -45,7 +48,7 @@ export class TwoFactorSetupComponent implements OnInit, OnDestroy {
tabbedHeader = true; tabbedHeader = true;
private destroy$ = new Subject<void>(); protected destroy$ = new Subject<void>();
private twoFactorAuthPolicyAppliesToActiveUser: boolean; private twoFactorAuthPolicyAppliesToActiveUser: boolean;
constructor( constructor(
@ -202,11 +205,15 @@ export class TwoFactorSetupComponent implements OnInit, OnDestroy {
this.evaluatePolicies(); this.evaluatePolicies();
} }
private async evaluatePolicies() { private evaluatePolicies() {
if (this.organizationId == null && this.providers.filter((p) => p.enabled).length === 1) { if (this.organizationId == null && this.providers.filter((p) => p.enabled).length === 1) {
this.showPolicyWarning = this.twoFactorAuthPolicyAppliesToActiveUser; this.showPolicyWarning = this.twoFactorAuthPolicyAppliesToActiveUser;
} else { } else {
this.showPolicyWarning = false; this.showPolicyWarning = false;
} }
} }
get isEnterpriseOrg() {
return this.organization?.planProductType === ProductType.Enterprise;
}
} }

View File

@ -1301,7 +1301,7 @@
}, },
"selectImportFolder": { "selectImportFolder": {
"message": "Select a folder" "message": "Select a folder"
}, },
"selectImportCollection": { "selectImportCollection": {
"message": "Select a collection" "message": "Select a collection"
}, },
@ -1317,7 +1317,7 @@
}, },
"importUnassignedItemsError": { "importUnassignedItemsError": {
"message": "File contains unassigned items." "message": "File contains unassigned items."
}, },
"selectFormat": { "selectFormat": {
"message": "Select the format of the import file" "message": "Select the format of the import file"
}, },
@ -1425,7 +1425,10 @@
"twoStepLoginDesc": { "twoStepLoginDesc": {
"message": "Secure your account by requiring an additional step when logging in." "message": "Secure your account by requiring an additional step when logging in."
}, },
"twoStepLoginOrganizationDescStart": { "twoStepLoginTeamsDesc": {
"message": "Enable two-step login for your organization."
},
"twoStepLoginEnterpriseDescStart": {
"message": "Enforce Bitwarden Two-step Login options for members by using the ", "message": "Enforce Bitwarden Two-step Login options for members by using the ",
"description": "This will be used as part of a larger sentence, broken up to include links. The full sentence will read 'Enforce Bitwarden Two-step Login options for members by using the Two-step Login Policy.'" "description": "This will be used as part of a larger sentence, broken up to include links. The full sentence will read 'Enforce Bitwarden Two-step Login options for members by using the Two-step Login Policy.'"
}, },
@ -7045,7 +7048,7 @@
}, },
"userEmailMissing": { "userEmailMissing": {
"message": "User email missing" "message": "User email missing"
}, },
"deviceTrusted": { "deviceTrusted": {
"message": "Device trusted" "message": "Device trusted"
}, },