From 200354d1816bf0095151d65eb75079e6625258c6 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Sun, 31 Mar 2024 09:55:53 +0800 Subject: [PATCH] Add url present check on email sign up --- packages/api/src/routers/auth/auth_router.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/api/src/routers/auth/auth_router.ts b/packages/api/src/routers/auth/auth_router.ts index 5a48e9634..01be9c019 100644 --- a/packages/api/src/routers/auth/auth_router.ts +++ b/packages/api/src/routers/auth/auth_router.ts @@ -500,6 +500,17 @@ export function authRouter() { ) } const { email, password, name, username, bio, pictureUrl } = req.body + + function isURLPresent(input: string): boolean { + const urlRegex = /(https?:\/\/[^\s]+)/g + return urlRegex.test(input) + } + + if (isURLPresent(email) || isURLPresent(name) || isURLPresent(username)) { + res.redirect(`${env.client.url}/auth/email-signup?errorCodes=UNKNOWN`) + return + } + // trim whitespace in email address const trimmedEmail = email.trim() try {