diff --git a/frontend/src/ts/pages/login.ts b/frontend/src/ts/pages/login.ts index 4ab069879..1cd5ba361 100644 --- a/frontend/src/ts/pages/login.ts +++ b/frontend/src/ts/pages/login.ts @@ -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, diff --git a/frontend/src/ts/utils/typo-list.ts b/frontend/src/ts/utils/typo-list.ts new file mode 100644 index 000000000..1caa11d76 --- /dev/null +++ b/frontend/src/ts/utils/typo-list.ts @@ -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", +];