From 7e3713ad757bc37f1f4e73767adf659908ed7147 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Fri, 15 Sep 2023 09:37:17 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20allowed=20email=20address?= =?UTF-8?q?=20matcher=20(#858)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/trpc/routers/auth.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/backend/trpc/routers/auth.ts b/packages/backend/trpc/routers/auth.ts index 3977488fc..d563330a3 100644 --- a/packages/backend/trpc/routers/auth.ts +++ b/packages/backend/trpc/routers/auth.ts @@ -52,7 +52,11 @@ const isEmailBlocked = (email: string) => { const allowedEmails = process.env.ALLOWED_EMAILS.split(","); // Check whether the email matches enough of the patterns specified in ALLOWED_EMAILS const isAllowed = allowedEmails.some((allowedEmail) => { - const regex = new RegExp(allowedEmail.trim().replace("*", ".*"), "i"); + const regex = new RegExp( + `^${allowedEmail + .replace(/[.+?^${}()|[\]\\]/g, "\\$&") + .replaceAll(/[*]/g, ".*")}$`, + ); return regex.test(email); });