mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-01 01:05:06 +08:00
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:
parent
8b8d9ebf01
commit
7668d2f7aa
2 changed files with 53 additions and 3 deletions
|
@ -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,
|
||||
|
|
34
frontend/src/ts/utils/typo-list.ts
Normal file
34
frontend/src/ts/utils/typo-list.ts
Normal 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",
|
||||
];
|
Loading…
Reference in a new issue