Skip to content

Commit

Permalink
feat(editor): Add additional email domains to our disallowed list for…
Browse files Browse the repository at this point in the history
… self-serve enterprise license (no-changelog) (#8161)
  • Loading branch information
alexgrozav authored Jan 19, 2024
1 parent e43cf2f commit d2b3c10
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/editor-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 20 additions & 17 deletions packages/editor-ui/src/components/PersonalizationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -188,6 +187,7 @@ export default defineComponent({
registerForEnterpriseTrial: false,
modalBus: createEventBus(),
formBus: createEventBus(),
domainBlocklist: [] as string[],
};
},
computed: {
Expand All @@ -203,28 +203,23 @@ 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;
}
const isSizeEligible = [COMPANY_SIZE_500_999, COMPANY_SIZE_1000_OR_MORE].includes(
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;
},
Expand Down Expand Up @@ -679,6 +674,9 @@ export default defineComponent({
return survey;
},
},
mounted() {
void this.loadDomainBlocklist();
},
methods: {
closeDialog() {
this.modalBus.emit('close');
Expand All @@ -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');
},
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d2b3c10

Please sign in to comment.