feat(editor): Add additional email domains to our disallowed list for self-serve enterprise license (no-changelog) (#8161)

This commit is contained in:
Alex Grozav 2024-01-19 15:21:49 +02:00 committed by GitHub
parent e43cf2fd71
commit d2b3c1048e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 17 deletions

View file

@ -52,6 +52,7 @@
"codemirror-lang-html-n8n": "^1.0.0",
"codemirror-lang-n8n-expression": "^0.2.0",
"dateformat": "^3.0.3",
"email-providers": "^2.0.1",
"esprima-next": "5.8.4",
"fast-json-stable-stringify": "^2.1.0",
"file-saver": "^2.0.2",

View file

@ -55,9 +55,6 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { mapStores } from 'pinia';
const SURVEY_VERSION = 'v4';
import {
COMPANY_SIZE_100_499,
COMPANY_SIZE_1000_OR_MORE,
@ -158,6 +155,8 @@ import { useExternalHooks } from '@/composables/useExternalHooks';
import { useUsageStore } from '@/stores/usage.store';
import { useMessage } from '@/composables/useMessage';
const SURVEY_VERSION = 'v4';
export default defineComponent({
name: 'PersonalizationModal',
components: { Modal },
@ -188,6 +187,7 @@ export default defineComponent({
registerForEnterpriseTrial: false,
modalBus: createEventBus(),
formBus: createEventBus(),
domainBlocklist: [] as string[],
};
},
computed: {
@ -203,7 +203,11 @@ export default defineComponent({
return this.usersStore.currentUser;
},
canRegisterForEnterpriseTrial() {
if (this.settingsStore.isCloudDeployment) {
if (
this.settingsStore.isCloudDeployment ||
this.domainBlocklist.length === 0 ||
!this.currentUser?.email
) {
return false;
}
@ -211,20 +215,11 @@ export default defineComponent({
this.formValues[COMPANY_SIZE_KEY],
);
const emailParts = (this.currentUser?.email || '@').split('@');
const emailParts = this.currentUser.email.split('@');
const emailDomain = emailParts[emailParts.length - 1];
const emailDomainParts = emailDomain.split('.');
const isEmailEligible = ![
'gmail',
'yahoo',
'hotmail',
'aol',
'live',
'outlook',
'icloud',
'mail',
'email',
].find((provider) => emailDomainParts.includes(provider));
const isEmailEligible = !this.domainBlocklist.find(
(blocklistedDomain) => emailDomain === blocklistedDomain,
);
return isSizeEligible && isEmailEligible;
},
@ -679,6 +674,9 @@ export default defineComponent({
return survey;
},
},
mounted() {
void this.loadDomainBlocklist();
},
methods: {
closeDialog() {
this.modalBus.emit('close');
@ -688,6 +686,11 @@ export default defineComponent({
void this.$router.replace({ name: VIEWS.NEW_WORKFLOW });
}
},
async loadDomainBlocklist() {
try {
this.domainBlocklist = (await import('email-providers/common.json')).default;
} catch (error) {}
},
onSave() {
this.formBus.emit('submit');
},

View file

@ -1066,6 +1066,9 @@ importers:
dateformat:
specifier: ^3.0.3
version: 3.0.3
email-providers:
specifier: ^2.0.1
version: 2.0.1
esprima-next:
specifier: 5.8.4
version: 5.8.4
@ -14668,6 +14671,11 @@ packages:
- '@vue/composition-api'
dev: false
/email-providers@2.0.1:
resolution: {integrity: sha512-lFWdT7sJilGO0UOO25D3urNH7Np1XTB/7GD/9nGM4YxNqAzkunuJyt9ZyG4cZ+UEGqH/lbK4vczg0B6NtyPflw==}
engines: {node: '>=16'}
dev: false
/emittery@0.13.1:
resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==}
engines: {node: '>=12'}