Added extra check to know if an organization is free (#4905)

This commit is contained in:
SmithThe4th 2023-03-07 17:25:33 -05:00 committed by GitHub
parent 1d01bfbb61
commit 85cd419d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -14,6 +14,7 @@ import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.serv
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
import { EventType } from "@bitwarden/common/enums/eventType";
import { ProductType } from "@bitwarden/common/enums/productType";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { PasswordRepromptService } from "@bitwarden/common/vault/abstractions/password-reprompt.service";
@ -86,11 +87,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On
this.cleanUp();
this.canAccessPremium = await this.stateService.getCanAccessPremium();
if (
this.cipher.type === CipherType.Login &&
this.cipher.login.totp &&
(this.cipher.organizationUseTotp || this.canAccessPremium)
) {
if (this.showTotp()) {
await this.totpUpdateCode();
const interval = this.totpService.getTimeInterval(this.cipher.login.totp);
await this.totpTick(interval);
@ -246,6 +243,15 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On
);
}
protected showTotp() {
return (
this.cipher.type === CipherType.Login &&
this.cipher.login.totp &&
this.organization?.planProductType != ProductType.Free &&
(this.cipher.organizationUseTotp || this.canAccessPremium)
);
}
private async totpTick(intervalSeconds: number) {
const epoch = Math.round(new Date().getTime() / 1000.0);
const mod = epoch % intervalSeconds;