From 182f9baa0f191847a71a97f1211bf9b5fb9fa973 Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Tue, 11 Feb 2025 11:12:56 -0800 Subject: [PATCH] Revert "[PM-5718] Fix free organization generating TOTP (#11918)" (#13357) This reverts commit 459fb1bcf4c7378acde4a507aeb881d38f73efa7. Co-authored-by: SmithThe4th --- apps/desktop/src/app/app.component.ts | 14 ------- apps/desktop/src/locales/en/messages.json | 9 ----- .../src/vault/app/vault/view.component.html | 10 ----- .../src/vault/app/vault/view.component.ts | 6 --- .../individual-vault/add-edit.component.ts | 5 +-- .../vault/components/add-edit.component.ts | 2 +- .../src/vault/components/view.component.ts | 18 ++++----- .../login-credentials-view.component.html | 8 ++-- .../login-credentials-view.component.ts | 38 +++---------------- 9 files changed, 20 insertions(+), 90 deletions(-) diff --git a/apps/desktop/src/app/app.component.ts b/apps/desktop/src/app/app.component.ts index 1f10b551fec..92b2c8fee37 100644 --- a/apps/desktop/src/app/app.component.ts +++ b/apps/desktop/src/app/app.component.ts @@ -318,20 +318,6 @@ export class AppComponent implements OnInit, OnDestroy { } break; } - case "upgradeOrganization": { - const upgradeConfirmed = await this.dialogService.openSimpleDialog({ - title: { key: "upgradeOrganization" }, - content: { key: "upgradeOrganizationDesc" }, - acceptButtonText: { key: "learnMore" }, - type: "info", - }); - if (upgradeConfirmed) { - this.platformUtilsService.launchUri( - "https://bitwarden.com/help/upgrade-from-individual-to-org/", - ); - } - break; - } case "emailVerificationRequired": { const emailVerificationConfirmed = await this.dialogService.openSimpleDialog({ title: { key: "emailVerificationRequired" }, diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 052992bfbc6..5bc1f216880 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -3502,15 +3502,6 @@ "allowScreenshotsDesc": { "message": "Allow the Bitwarden desktop application to be captured in screenshots and viewed in remote desktop sessions. Disabling this will prevent access on some external displays." }, - "organizationUpgradeRequired": { - "message": "Organization upgrade required" - }, - "upgradeOrganization": { - "message": "Upgrade organization" - }, - "upgradeOrganizationDesc": { - "message": "This feature is not available for free organizations. Switch to a paid plan to unlock more features." - }, "confirmWindowStillVisibleTitle": { "message": "Confirm window still visible" }, diff --git a/apps/desktop/src/vault/app/vault/view.component.html b/apps/desktop/src/vault/app/vault/view.component.html index f589ba53046..59e609312d7 100644 --- a/apps/desktop/src/vault/app/vault/view.component.html +++ b/apps/desktop/src/vault/app/vault/view.component.html @@ -186,16 +186,6 @@ -
-
- {{ "verificationCodeTotp" | i18n }} - - {{ "organizationUpgradeRequired" | i18n }} - - -
-
diff --git a/apps/desktop/src/vault/app/vault/view.component.ts b/apps/desktop/src/vault/app/vault/view.component.ts index 136a537dd37..aee1f34437b 100644 --- a/apps/desktop/src/vault/app/vault/view.component.ts +++ b/apps/desktop/src/vault/app/vault/view.component.ts @@ -159,10 +159,4 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro this.messagingService.send("premiumRequired"); } } - - upgradeOrganization() { - this.messagingService.send("upgradeOrganization", { - organizationId: this.cipher.organizationId, - }); - } } diff --git a/apps/web/src/app/vault/individual-vault/add-edit.component.ts b/apps/web/src/app/vault/individual-vault/add-edit.component.ts index 02dcbc30161..a794687c45b 100644 --- a/apps/web/src/app/vault/individual-vault/add-edit.component.ts +++ b/apps/web/src/app/vault/individual-vault/add-edit.component.ts @@ -66,7 +66,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On protected messagingService: MessagingService, eventCollectionService: EventCollectionService, protected policyService: PolicyService, - protected organizationService: OrganizationService, + organizationService: OrganizationService, logService: LogService, passwordRepromptService: PasswordRepromptService, dialogService: DialogService, @@ -303,8 +303,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On this.cipher.type === CipherType.Login && this.cipher.login.totp && this.organization?.productTierType != ProductTierType.Free && - ((this.canAccessPremium && this.cipher.organizationId == null) || - this.cipher.organizationUseTotp) + (this.cipher.organizationUseTotp || this.canAccessPremium) ); } diff --git a/libs/angular/src/vault/components/add-edit.component.ts b/libs/angular/src/vault/components/add-edit.component.ts index 26f645d89ef..7a0c8ae2669 100644 --- a/libs/angular/src/vault/components/add-edit.component.ts +++ b/libs/angular/src/vault/components/add-edit.component.ts @@ -125,7 +125,7 @@ export class AddEditComponent implements OnInit, OnDestroy { protected policyService: PolicyService, protected logService: LogService, protected passwordRepromptService: PasswordRepromptService, - protected organizationService: OrganizationService, + private organizationService: OrganizationService, protected dialogService: DialogService, protected win: Window, protected datePipe: DatePipe, diff --git a/libs/angular/src/vault/components/view.component.ts b/libs/angular/src/vault/components/view.component.ts index bec4ae52206..b746c5b0062 100644 --- a/libs/angular/src/vault/components/view.component.ts +++ b/libs/angular/src/vault/components/view.component.ts @@ -33,7 +33,7 @@ import { CollectionId } from "@bitwarden/common/types/guid"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service"; -import { FieldType, CipherType } from "@bitwarden/common/vault/enums"; +import { CipherType, FieldType } from "@bitwarden/common/vault/enums"; import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type"; import { Launchable } from "@bitwarden/common/vault/interfaces/launchable"; import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view"; @@ -65,7 +65,6 @@ export class ViewComponent implements OnDestroy, OnInit { showPrivateKey: boolean; canAccessPremium: boolean; showPremiumRequiredTotp: boolean; - showUpgradeRequiredTotp: boolean; totpCode: string; totpCodeFormatted: string; totpDash: number; @@ -161,25 +160,22 @@ export class ViewComponent implements OnDestroy, OnInit { this.billingAccountProfileStateService.hasPremiumFromAnySource$(activeUserId), ); this.showPremiumRequiredTotp = - this.cipher.login.totp && !this.canAccessPremium && !this.cipher.organizationId; + this.cipher.login.totp && !this.canAccessPremium && !this.cipher.organizationUseTotp; this.canDeleteCipher$ = this.cipherAuthorizationService.canDeleteCipher$(this.cipher, [ this.collectionId as CollectionId, ]); - this.showUpgradeRequiredTotp = - this.cipher.login.totp && this.cipher.organizationId && !this.cipher.organizationUseTotp; - if (this.cipher.folderId) { this.folder = await ( await firstValueFrom(this.folderService.folderViews$(activeUserId)) ).find((f) => f.id == this.cipher.folderId); } - const canGenerateTotp = this.cipher.organizationId - ? this.cipher.organizationUseTotp - : this.canAccessPremium; - - if (this.cipher.type === CipherType.Login && this.cipher.login.totp && canGenerateTotp) { + if ( + this.cipher.type === CipherType.Login && + this.cipher.login.totp && + (this.cipher.organizationUseTotp || this.canAccessPremium) + ) { await this.totpUpdateCode(); const interval = this.totpService.getTimeInterval(this.cipher.login.totp); await this.totpTick(interval); diff --git a/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html b/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html index b4a0d4841f8..8503604bf7c 100644 --- a/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html +++ b/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.html @@ -116,7 +116,7 @@ {{ "verificationCodeTotp" | i18n }}
diff --git a/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.ts b/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.ts index 41a4828f645..c95b2040fd2 100644 --- a/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.ts +++ b/libs/vault/src/cipher-view/login-credentials/login-credentials-view.component.ts @@ -2,15 +2,7 @@ // @ts-strict-ignore import { CommonModule, DatePipe } from "@angular/common"; import { Component, inject, Input } from "@angular/core"; -import { - BehaviorSubject, - combineLatest, - filter, - map, - Observable, - shareReplay, - switchMap, -} from "rxjs"; +import { Observable, switchMap } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; @@ -21,13 +13,13 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic import { PremiumUpgradePromptService } from "@bitwarden/common/vault/abstractions/premium-upgrade-prompt.service"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { - BadgeModule, - ColorPasswordModule, FormFieldModule, - IconButtonModule, SectionComponent, SectionHeaderComponent, TypographyModule, + IconButtonModule, + BadgeModule, + ColorPasswordModule, } from "@bitwarden/components"; import { BitTotpCountdownComponent } from "../../components/totp-countdown/totp-countdown.component"; @@ -57,31 +49,13 @@ type TotpCodeValues = { ], }) export class LoginCredentialsViewComponent { - @Input() - get cipher(): CipherView { - return this._cipher$.value; - } - set cipher(value: CipherView) { - this._cipher$.next(value); - } - private _cipher$ = new BehaviorSubject(null); + @Input() cipher: CipherView; - private _userHasPremium$: Observable = this.accountService.activeAccount$.pipe( + isPremium$: Observable = this.accountService.activeAccount$.pipe( switchMap((account) => this.billingAccountProfileStateService.hasPremiumFromAnySource$(account.id), ), ); - - allowTotpGeneration$: Observable = combineLatest([ - this._userHasPremium$, - this._cipher$.pipe(filter((c) => c != null)), - ]).pipe( - map(([userHasPremium, cipher]) => { - // User premium status only applies to personal ciphers, organizationUseTotp applies to organization ciphers - return (userHasPremium && cipher.organizationId == null) || cipher.organizationUseTotp; - }), - shareReplay({ refCount: true, bufferSize: 1 }), - ); showPasswordCount: boolean = false; passwordRevealed: boolean = false; totpCodeCopyObj: TotpCodeValues;