Skip to content

Commit ee4ba8c

Browse files
authored
Merge pull request #1454 from AppQuality/UN-1913
feat: add disposable email validation using fakefilter package
2 parents 25e6c12 + 02fe00d commit ee4ba8c

File tree

8 files changed

+37
-220
lines changed

8 files changed

+37
-220
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"i18n-iso-countries": "^7.3.0",
2323
"i18next": "^23.15.1",
2424
"i18next-browser-languagedetector": "^8.0.0",
25+
"mailchecker": "^6.0.19",
2526
"motion": "^12.16.0",
2627
"qs": "^6.10.3",
2728
"query-string": "^7.1.1",
@@ -130,4 +131,4 @@
130131
"*.{tsx,ts,js,css,md}": "prettier --write"
131132
},
132133
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
133-
}
134+
}

src/common/disposableEmail.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import MailChecker from 'mailchecker';
2+
3+
export function isDisposableEmail(email: string): any {
4+
return !MailChecker.isValid(email);
5+
}

src/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,7 @@
14541454
"SIGNUP_FORM_COMPANY_SIZE_PLACEHOLDER": "Select company size",
14551455
"SIGNUP_FORM_CTA_RETURN_TO_UNGUESS_LANDING": "or visit <unguess-link>UNGUESS website</unguess-link>",
14561456
"SIGNUP_FORM_EMAIL_ALREADY_TAKEN": "Error: User with provided email already exists",
1457+
"SIGNUP_FORM_EMAIL_DISPOSABLE_NOT_ALLOWED": "Temporary email addresses are not allowed",
14571458
"SIGNUP_FORM_EMAIL_ERROR_SERVER_MAIL_CHECK": "Oops! Check your email format",
14581459
"SIGNUP_FORM_EMAIL_IS_REQUIRED": "This field is required",
14591460
"SIGNUP_FORM_EMAIL_LABEL": "Work Email",

src/locales/it/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@
14981498
"SIGNUP_FORM_COMPANY_SIZE_PLACEHOLDER": "",
14991499
"SIGNUP_FORM_CTA_RETURN_TO_UNGUESS_LANDING": "",
15001500
"SIGNUP_FORM_EMAIL_ALREADY_TAKEN": "",
1501+
"SIGNUP_FORM_EMAIL_DISPOSABLE_NOT_ALLOWED": "",
15011502
"SIGNUP_FORM_EMAIL_ERROR_SERVER_MAIL_CHECK": "",
15021503
"SIGNUP_FORM_EMAIL_IS_REQUIRED": "",
15031504
"SIGNUP_FORM_EMAIL_LABEL": "",

src/pages/JoinPage/Steps/Step1.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useEffect, useState } from 'react';
1717
import { Trans, useTranslation } from 'react-i18next';
1818
import { appTheme } from 'src/app/theme';
1919
import { PasswordRequirements } from 'src/common/components/PasswordRequirements';
20+
import { isDisposableEmail } from 'src/common/disposableEmail';
2021
import { useSendGTMevent } from 'src/hooks/useGTMevent';
2122
import { JoinFormValues } from '../valuesType';
2223
import { ButtonContainer } from './ButtonContainer';
@@ -66,6 +67,22 @@ export const Step1 = () => {
6667
let error;
6768
let error_event;
6869
if (status?.isInvited) return error;
70+
if (value) {
71+
const isDisposable = isDisposableEmail(value);
72+
73+
if (isDisposable) {
74+
error = t('SIGNUP_FORM_EMAIL_DISPOSABLE_NOT_ALLOWED');
75+
error_event = 'SIGNUP_FORM_EMAIL_DISPOSABLE_NOT_ALLOWED';
76+
sendGTMevent({
77+
event: 'sign-up-flow',
78+
category: 'not set',
79+
action: 'validate email',
80+
content: `error: ${error_event}`,
81+
target: `is invited: ${status?.isInvited}`,
82+
});
83+
return error;
84+
}
85+
}
6986
const res = await fetch(
7087
`${process.env.REACT_APP_API_URL}/users/by-email/${value}`,
7188
{

tests/e2e/join/index.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,16 @@ test.describe('The Join page first step - case new user', () => {
7575
await expect(step1.elements().emailError()).toHaveText(
7676
i18n.t('SIGNUP_FORM_EMAIL_IS_REQUIRED')
7777
);
78-
await step1.fillEmail('invalid-email');
78+
await step1.fillEmail('invalid-email@');
7979
await expect(
8080
page.getByText(i18n.t('SIGNUP_FORM_EMAIL_MUST_BE_A_VALID_EMAIL'))
8181
).toBeVisible();
8282

83+
await step1.fillEmail('fake-email@mailinator.com');
84+
await expect(
85+
page.getByText(i18n.t('SIGNUP_FORM_EMAIL_DISPOSABLE_NOT_ALLOWED'))
86+
).toBeVisible();
87+
8388
await step1.fillRegisteredEmail();
8489
await expect(
8590
page.getByText(i18n.t('SIGNUP_FORM_EMAIL_ALREADY_TAKEN'))
@@ -94,7 +99,6 @@ test.describe('The Join page first step - case new user', () => {
9499
await expect(step1.elements().container()).not.toBeVisible();
95100
await expect(step2.elements().container()).toBeVisible();
96101
});
97-
test('display two links to go to app.unguess and a link to terms and conditions', async () => {});
98102
});
99103

100104
test.describe('The Join page second step', () => {

tests/e2e/login/index.spec.ts

Lines changed: 0 additions & 217 deletions
This file was deleted.

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6266,6 +6266,11 @@ lru-cache@^5.1.1:
62666266
dependencies:
62676267
yallist "^3.0.2"
62686268

6269+
mailchecker@^6.0.19:
6270+
version "6.0.19"
6271+
resolved "https://registry.yarnpkg.com/mailchecker/-/mailchecker-6.0.19.tgz#7d0bc89e6f846a2dc1adb44e065e4d146e8f7d8d"
6272+
integrity sha512-a7yghUa0IC1n6OkSJIqCSw2HS8ujKJGBJcRkjhHiKvHqPU3JB28Yze9o90L52r6lA/sp/EBveDXOWbozcdmxYg==
6273+
62696274
make-error@^1.1.1:
62706275
version "1.3.6"
62716276
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"

0 commit comments

Comments
 (0)