Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Fix allowed email address matcher (#858)

Luke Vella7e3713ad757b
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);
});