Totp field now requires premium
This commit is contained in:
parent
5d6eec9067
commit
8015f797c8
|
@ -2,7 +2,7 @@ import "./item-icon";
|
|||
import "./popover";
|
||||
import { until } from "lit/directives/until.js";
|
||||
import { repeat } from "lit/directives/repeat.js";
|
||||
import { VaultItemID, Field, FieldDef, FIELD_DEFS, VaultItem } from "@padloc/core/src/item";
|
||||
import { VaultItemID, Field, FieldDef, FIELD_DEFS, VaultItem, FieldType } from "@padloc/core/src/item";
|
||||
import { translate as $l } from "@padloc/locale/src/translate";
|
||||
import { AttachmentInfo } from "@padloc/core/src/attachment";
|
||||
import { parseURL } from "@padloc/core/src/otp";
|
||||
|
@ -184,6 +184,12 @@ export class ItemView extends Routing(StateMixin(LitElement)) {
|
|||
: checkFeatureDisabled(app.getAccountFeatures().attachments);
|
||||
}
|
||||
|
||||
private _checkTotpDisabled() {
|
||||
return this._org
|
||||
? checkFeatureDisabled(app.getOrgFeatures(this._org).totpField, this._org.isOwner(app.account!))
|
||||
: checkFeatureDisabled(app.getAccountFeatures().totpField);
|
||||
}
|
||||
|
||||
private _moveField(index: number, target: "up" | "down" | number) {
|
||||
const field = this._fields[index];
|
||||
this._fields.splice(index, 1);
|
||||
|
@ -634,11 +640,11 @@ export class ItemView extends Routing(StateMixin(LitElement)) {
|
|||
}
|
||||
|
||||
private async _addField(fieldDef: FieldDef) {
|
||||
// const fieldDef = await this._fieldTypeDialog.show();
|
||||
//
|
||||
// if (!fieldDef) {
|
||||
// return;
|
||||
// }
|
||||
if (fieldDef.type === FieldType.Totp) {
|
||||
if (this._checkTotpDisabled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this._fields.push(new Field({ name: fieldDef.name, value: "", type: fieldDef.type }));
|
||||
this.requestUpdate();
|
||||
|
|
|
@ -154,20 +154,6 @@ export const FIELD_DEFS: { [t in FieldType]: FieldDef } = {
|
|||
return parts.join(" ");
|
||||
},
|
||||
},
|
||||
[FieldType.Totp]: {
|
||||
type: FieldType.Totp,
|
||||
pattern: /^([A-Z2-7=]{8})+$/i,
|
||||
matchPattern: /^([A-Z2-7=]{8})+$/i,
|
||||
mask: false,
|
||||
multiline: false,
|
||||
icon: "totp",
|
||||
get name() {
|
||||
return $l("2FA Token");
|
||||
},
|
||||
async transform(value: string) {
|
||||
return await totp(base32ToBytes(value));
|
||||
},
|
||||
},
|
||||
[FieldType.Phone]: {
|
||||
type: FieldType.Phone,
|
||||
pattern: /.*/,
|
||||
|
@ -215,6 +201,20 @@ export const FIELD_DEFS: { [t in FieldType]: FieldDef } = {
|
|||
return $l("Other");
|
||||
},
|
||||
},
|
||||
[FieldType.Totp]: {
|
||||
type: FieldType.Totp,
|
||||
pattern: /^([A-Z2-7=]{8})+$/i,
|
||||
matchPattern: /^([A-Z2-7=]{8})+$/i,
|
||||
mask: false,
|
||||
multiline: false,
|
||||
icon: "totp",
|
||||
get name() {
|
||||
return $l("Authenticator");
|
||||
},
|
||||
async transform(value: string) {
|
||||
return await totp(base32ToBytes(value));
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export class Field extends Serializable {
|
||||
|
|
|
@ -87,6 +87,9 @@ export class AccountFeatures extends Serializable {
|
|||
|
||||
@AsSerializable(Feature)
|
||||
billing: Feature = new Feature();
|
||||
|
||||
@AsSerializable(Feature)
|
||||
totpField: Feature = new Feature();
|
||||
}
|
||||
|
||||
export class OrgFeatures extends Serializable {
|
||||
|
@ -112,6 +115,9 @@ export class OrgFeatures extends Serializable {
|
|||
|
||||
@AsSerializable(OrgFeature)
|
||||
directorySync: OrgFeature = new OrgFeature();
|
||||
|
||||
@AsSerializable(OrgFeature)
|
||||
totpField: OrgFeature = new OrgFeature();
|
||||
}
|
||||
|
||||
export class AccountProvisioning extends Storable {
|
||||
|
|
|
@ -90,6 +90,7 @@ export class StripeProvisioner extends BasicProvisioner {
|
|||
"Shared vaults",
|
||||
"Encrypted file storage",
|
||||
"Security Report",
|
||||
"Built-in Authenticator",
|
||||
],
|
||||
},
|
||||
[Tier.Premium]: {
|
||||
|
@ -104,6 +105,7 @@ export class StripeProvisioner extends BasicProvisioner {
|
|||
"Multi-Factor Authentication",
|
||||
"Up to 1GB encrypted file storage",
|
||||
"Security Report",
|
||||
"Built-in Authenticator",
|
||||
],
|
||||
disabledFeatures: ["Shared Vaults"],
|
||||
},
|
||||
|
@ -119,6 +121,8 @@ export class StripeProvisioner extends BasicProvisioner {
|
|||
"Multi-Factor Authentication",
|
||||
"Up to 1GB encrypted file storage",
|
||||
"Security Report",
|
||||
"Built-in Authenticator",
|
||||
"Share data between up to 5 users",
|
||||
"Up to 5 Shared Vaults",
|
||||
],
|
||||
disabledFeatures: [],
|
||||
|
@ -135,6 +139,7 @@ export class StripeProvisioner extends BasicProvisioner {
|
|||
"Multi-Factor Authentication",
|
||||
"Up to 5GB encrypted file storage",
|
||||
"Security Report",
|
||||
"Built-in Authenticator",
|
||||
"Up to 20 Shared Vaults",
|
||||
"Up to 10 groups for easier permission management",
|
||||
],
|
||||
|
@ -152,6 +157,7 @@ export class StripeProvisioner extends BasicProvisioner {
|
|||
"Multi-Factor Authentication",
|
||||
"Up to 20GB encrypted file storage",
|
||||
"Security Report",
|
||||
"Built-in Authenticator",
|
||||
"Unlimited Vaults",
|
||||
"Unlimited Groups",
|
||||
"Directory Sync / Automatic Provisioning",
|
||||
|
@ -418,6 +424,15 @@ export class StripeProvisioner extends BasicProvisioner {
|
|||
true,
|
||||
"File Storage"
|
||||
);
|
||||
features.totpField.disabled = true;
|
||||
features.totpField.message = await this._getUpgradeMessage(
|
||||
customer,
|
||||
[Tier.Premium, Tier.Family, Tier.Team, Tier.Business],
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
"Authenticator"
|
||||
);
|
||||
features.securityReport.disabled = true;
|
||||
features.securityReport.message = await this._getUpgradeMessage(
|
||||
customer,
|
||||
|
|
Loading…
Reference in New Issue