Email typo (#4430) Warrobot10 Miodec

* Add typo_list.json

Please check this. This is a work in progress, and the only reason I committed is so what I did is saved.

* Add detection of email typo functionality.

* Add @ at each typo

* Fix styling issue

* Fix styling issue 2

* Fix styling issue 3

* pretty fix

* changed file to a module

* changed file name

* fixed indentation

* fixed messy nesting

* added some more typos

---------

Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
Warrobot10 2023-07-10 22:24:17 +10:00 committed by GitHub
parent 8b8d9ebf01
commit 7668d2f7aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import * as Notifications from "../elements/notifications";
import { InputIndicator } from "../elements/input-indicator";
import * as Skeleton from "../popups/skeleton";
import * as Misc from "../utils/misc";
import TypoList from "../utils/typo-list";
export function enableSignUpButton(): void {
$(".page.pageLogin .register.side .button").removeClass("disabled");
@ -41,7 +42,9 @@ export function hidePreloader(): void {
export const updateSignupButton = (): void => {
if (
nameIndicator.get() !== "available" ||
(emailIndicator.get() !== "valid" && emailIndicator.get() !== "edu") ||
(emailIndicator.get() !== "valid" &&
emailIndicator.get() !== "typo" &&
emailIndicator.get() !== "edu") ||
verifyEmailIndicator.get() !== "match" ||
passwordIndicator.get() !== "good" ||
verifyPasswordIndicator.get() !== "match"
@ -81,13 +84,22 @@ const checkNameDebounced = debounce(1000, async () => {
});
const checkEmail = (): void => {
const email = $(".page.pageLogin .register.side .emailInput").val() as string;
const emailRegex =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const educationRegex = /@.*(education|\.edu$|\.edu\.|\.ac\.|\.sch\.)/i;
const email = $(".page.pageLogin .register.side .emailInput").val() as string;
const emailHasTypo = TypoList.some((typo) => {
return email.endsWith(typo);
});
if (emailRegex.test(email)) {
if (educationRegex.test(email)) {
if (emailHasTypo) {
emailIndicator.show(
"typo",
"Please check your email address, it may contain a typo."
);
} else if (educationRegex.test(email)) {
emailIndicator.show(
"edu",
"Some education emails will fail to receive our messages. Consider using a personal email address."
@ -187,6 +199,10 @@ const emailIndicator = new InputIndicator(
icon: "fa-times",
level: -1,
},
typo: {
icon: "fa-exclamation-triangle",
level: 1,
},
edu: {
icon: "fa-exclamation-triangle",
level: 1,

View file

@ -0,0 +1,34 @@
export default [
"@gmaill.com",
"@gamil.com",
"@gnail.com",
"@gmil.com",
"@gamail.com",
"@hotmai.com",
"@gmial.com",
"@hotmal.com",
"@yaho.com",
"@outlokk.com",
"@gmil.com",
"@hotmial.com",
"@yahooo.com",
"@otulook.com",
"@gamil.com",
"@hotnail.com",
"@yaoo.com",
"@outlok.com",
"@gmail.cmo",
"@hotmail.cmo",
"@yahho.com",
"@outloook.com",
"@gmaail.com",
"@hottmail.com",
"@yaho.com",
"@outllok.com",
".comm",
".con",
".cmo",
".coom",
".cim",
".vom",
];