From 43339eac2146ed67fc1c781d99ad7a805a39b165 Mon Sep 17 00:00:00 2001 From: Dominik Date: Thu, 9 Nov 2023 16:23:51 +0100 Subject: [PATCH 1/7] feat: add billing email validation --- app/components/billing/payment-details-tab.js | 17 +++++++++++++++++ .../components/billing/payment-details-tab.hbs | 11 ++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/components/billing/payment-details-tab.js b/app/components/billing/payment-details-tab.js index 8128a620fb..2c34cbe1c7 100644 --- a/app/components/billing/payment-details-tab.js +++ b/app/components/billing/payment-details-tab.js @@ -152,6 +152,23 @@ export default Component.extend({ onCaptchaResolved(reCaptchaResponse) { this.updatePaymentDetails.perform(reCaptchaResponse); }, + validateBillingEmails(billingEmailField) { + if (!billingEmailField) { + return true; + } + + const emailRegex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i; + const emails = billingEmailField.split(',').map(email => email.trim()); + + const invalidEmails = emails.filter(email => !emailRegex.test(email)); + + if (invalidEmails.length > 0) { + const invalidEmailsList = invalidEmails.join(', '); + return `The following email addresses are not valid: ${invalidEmailsList}`; + } + + return true; + }, submit() { if (!this.enableSubmit || this.disableForm) return; window.grecaptcha.execute(); diff --git a/app/templates/components/billing/payment-details-tab.hbs b/app/templates/components/billing/payment-details-tab.hbs index 51bdef1643..bfb9481d89 100644 --- a/app/templates/components/billing/payment-details-tab.hbs +++ b/app/templates/components/billing/payment-details-tab.hbs @@ -49,7 +49,7 @@

{{stripeError.message}}

{{/if}} - + - +
 
- + - +
{{/if}}
- + {{#if this.showNonZeroVatConfirmation}}
From b1f51be74d744a540b54477fef9b15308b138390 Mon Sep 17 00:00:00 2001 From: Dominik Date: Fri, 10 Nov 2023 11:52:01 +0100 Subject: [PATCH 2/7] fix: correct regex for email validation --- app/components/billing/payment-details-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/billing/payment-details-tab.js b/app/components/billing/payment-details-tab.js index 2c34cbe1c7..2203716280 100644 --- a/app/components/billing/payment-details-tab.js +++ b/app/components/billing/payment-details-tab.js @@ -157,7 +157,7 @@ export default Component.extend({ return true; } - const emailRegex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i; + const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; const emails = billingEmailField.split(',').map(email => email.trim()); const invalidEmails = emails.filter(email => !emailRegex.test(email)); From 04a94ce5dbe08b9d8b04f027fc7f543fa51008f2 Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 13 Nov 2023 08:56:42 +0100 Subject: [PATCH 3/7] Trigger CI From 2504e09757242106248a0d6a352c45c42d898687 Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 13 Nov 2023 09:28:24 +0100 Subject: [PATCH 4/7] test: fix attempt --- tests/integration/components/billing/payment-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/components/billing/payment-test.js b/tests/integration/components/billing/payment-test.js index 97405a1ccd..c966c4d0ee 100644 --- a/tests/integration/components/billing/payment-test.js +++ b/tests/integration/components/billing/payment-test.js @@ -32,7 +32,7 @@ module('Integration | Component | billing-payment', function (hooks) { firstName: '', lastName: '', companyName: '', - billingEmail: '', + billingEmail: 'some@email.com', street: '', billingSuite: '', billingCity: '', From c2e68c9d9928e9bb08e599979c16fccf09b7bb59 Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 13 Nov 2023 11:55:52 +0100 Subject: [PATCH 5/7] feat: add validation on initial account setup --- app/components/billing/first-plan.js | 18 +++++++++++++++++- .../components/billing/first-plan.hbs | 14 +++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/components/billing/first-plan.js b/app/components/billing/first-plan.js index b9d5e96fc2..d55acc8219 100644 --- a/app/components/billing/first-plan.js +++ b/app/components/billing/first-plan.js @@ -286,7 +286,23 @@ export default Component.extend({ }, togglePlanDetails() { this.set('planDetailsVisible', !this.planDetailsVisible); - } + }, + validateBillingEmails(billingEmailField) { + if (!billingEmailField) { + return true; + } + + const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; + const emails = billingEmailField.split(',').map(email => email.trim()); + const invalidEmails = emails.filter(email => !emailRegex.test(email)); + + if (invalidEmails.length > 0) { + const invalidEmailsList = invalidEmails.join(', '); + return `The following email addresses are not valid: ${invalidEmailsList}`; + } + + return true; + }, } }); diff --git a/app/templates/components/billing/first-plan.hbs b/app/templates/components/billing/first-plan.hbs index 6ef9c437ac..f7cfc2a009 100644 --- a/app/templates/components/billing/first-plan.hbs +++ b/app/templates/components/billing/first-plan.hbs @@ -24,7 +24,7 @@
-
+
@@ -38,7 +38,7 @@
@@ -158,7 +158,7 @@ {{#unless this.isTrial}}

{{format-currency this.selectedPlan.startingPrice floor="true"}}{{ if this.selectedPlan.isAnnual '/annualy' '/monthly'}}

- + {{#if this.planDetailsVisible}} @@ -174,7 +174,7 @@

Linux, Windows, macOS, FreeBSD

- + {{#if this.selectedPlan.hasOSSCreditAddons}}

{{this.selectedPlan.publicCredits}} OSS Credits {{#if this.isTrial}} We will charge you $1 and refund you in 7 days. This is needed to make sure your card - + is valid. By clicking on "Verify Your Account" you agree to Travis CI Terms and Privacy Policy. @@ -227,10 +227,10 @@ will not be able to use Travis CI features. {{else}} - + You'll be charged {{format-currency this.selectedPlan.startingPrice floor="true"}} {{ if this.selectedPlan.isAnnual 'annualy' 'monthly'}} until you cancel your subscription. Previous - + charges won't be refunded when you cancel unless it's legally required. By clicking on "{{this.getActivateButtonText}}" you agree to Travis CI Terms and Privacy Policy. From ce1b84bddafc9510fa0685a793543de291e20435 Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 13 Nov 2023 12:16:43 +0100 Subject: [PATCH 6/7] refactor: remove not needed bracket --- app/templates/account-activation.hbs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/templates/account-activation.hbs b/app/templates/account-activation.hbs index 7ee21ef775..772d17f2b8 100644 --- a/app/templates/account-activation.hbs +++ b/app/templates/account-activation.hbs @@ -14,8 +14,7 @@ + > - < From 4c37165155f9f5233244d2ec6a19255f47007643 Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 13 Nov 2023 13:00:14 +0100 Subject: [PATCH 7/7] refactor: replace old email validation with new --- app/templates/components/billing/first-plan.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/components/billing/first-plan.hbs b/app/templates/components/billing/first-plan.hbs index f7cfc2a009..3f0d47c243 100644 --- a/app/templates/components/billing/first-plan.hbs +++ b/app/templates/components/billing/first-plan.hbs @@ -38,7 +38,7 @@