mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-06 14:46:47 +08:00
fix: email schema mismatch between frontend and backend
This commit is contained in:
parent
0b3f5aaa16
commit
3ce9e63410
1 changed files with 3 additions and 4 deletions
|
@ -6,6 +6,7 @@ import { InputIndicator } from "../elements/input-indicator";
|
|||
import * as Skeleton from "../utils/skeleton";
|
||||
import * as Misc from "../utils/misc";
|
||||
import TypoList from "../utils/typo-list";
|
||||
import { z } from "zod";
|
||||
|
||||
export function enableSignUpButton(): void {
|
||||
$(".page.pageLogin .register.side button").prop("disabled", false);
|
||||
|
@ -81,8 +82,6 @@ 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 =
|
||||
/@.*(student|education|school|\.edu$|\.edu\.|\.ac\.|\.sch\.)/i;
|
||||
|
||||
|
@ -90,7 +89,7 @@ const checkEmail = (): void => {
|
|||
return email.endsWith(typo);
|
||||
});
|
||||
|
||||
if (emailRegex.test(email)) {
|
||||
if (z.string().email().safeParse(email).success) {
|
||||
if (emailHasTypo) {
|
||||
emailIndicator.show(
|
||||
"typo",
|
||||
|
@ -105,7 +104,7 @@ const checkEmail = (): void => {
|
|||
emailIndicator.show("valid");
|
||||
}
|
||||
} else {
|
||||
emailIndicator.show("invalid");
|
||||
emailIndicator.show("invalid", "Please enter a valid email address.");
|
||||
}
|
||||
|
||||
updateSignupButton();
|
||||
|
|
Loading…
Add table
Reference in a new issue