fix: email schema mismatch between frontend and backend

This commit is contained in:
Miodec 2025-02-03 14:39:31 +01:00
parent 0b3f5aaa16
commit 3ce9e63410

View file

@ -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();