mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
Added extra check to know if an organization is free (#4905)
This commit is contained in:
@@ -14,6 +14,7 @@ import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.serv
|
|||||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||||
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
|
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
|
||||||
import { EventType } from "@bitwarden/common/enums/eventType";
|
import { EventType } from "@bitwarden/common/enums/eventType";
|
||||||
|
import { ProductType } from "@bitwarden/common/enums/productType";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { PasswordRepromptService } from "@bitwarden/common/vault/abstractions/password-reprompt.service";
|
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.cleanUp();
|
||||||
|
|
||||||
this.canAccessPremium = await this.stateService.getCanAccessPremium();
|
this.canAccessPremium = await this.stateService.getCanAccessPremium();
|
||||||
if (
|
if (this.showTotp()) {
|
||||||
this.cipher.type === CipherType.Login &&
|
|
||||||
this.cipher.login.totp &&
|
|
||||||
(this.cipher.organizationUseTotp || this.canAccessPremium)
|
|
||||||
) {
|
|
||||||
await this.totpUpdateCode();
|
await this.totpUpdateCode();
|
||||||
const interval = this.totpService.getTimeInterval(this.cipher.login.totp);
|
const interval = this.totpService.getTimeInterval(this.cipher.login.totp);
|
||||||
await this.totpTick(interval);
|
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) {
|
private async totpTick(intervalSeconds: number) {
|
||||||
const epoch = Math.round(new Date().getTime() / 1000.0);
|
const epoch = Math.round(new Date().getTime() / 1000.0);
|
||||||
const mod = epoch % intervalSeconds;
|
const mod = epoch % intervalSeconds;
|
||||||
|
|||||||
Reference in New Issue
Block a user