diff --git a/routes/auth/send-mail.ts b/routes/auth/send-mail.ts index 0d31855..2bf9d2a 100644 --- a/routes/auth/send-mail.ts +++ b/routes/auth/send-mail.ts @@ -44,8 +44,12 @@ export default async function Route_Auth_Sendmail(req: Request, res: Response, n const [username, domain] = lowercaseEmail.split("@"); const parsedEmail = `${username.replace(".", "")}@${domain}`.replace(/\+.*@/g, "@"); + Logger.log("email", bodyPayload.data.email); + Logger.log("lowercaseEmail", lowercaseEmail); + Logger.log("parsedEmail", parsedEmail); + if (!isAdmin(req)) { - if (/^[a-zA-Z0-9._%-]+@edu\.devinci\.fr$/.test(parsedEmail) === false) { + if (/^[a-zA-Z0-9_-]+@edu\.devinci\.fr$/.test(parsedEmail) === false) { return Status.send(req, next, { status: 400, error: "errors.auth.invalid.email" diff --git a/tests/e2e/auth.test.ts b/tests/e2e/auth.test.ts index 5f50b9b..937a754 100644 --- a/tests/e2e/auth.test.ts +++ b/tests/e2e/auth.test.ts @@ -30,7 +30,7 @@ describe("Test authentication", () => { }); test("should get 'too many requests' error", async () => { - const res = await post(app, "/auth/send-mail", { email: email }); + const res = await post(app, "/auth/send-mail", { email: email }, { "X-ADMIN-KEY": globals.env.ADMIN_TOKEN }); expect(res.body).toStrictEqual({ masterStatus: 429,