diff --git a/packages/api/src/routers/auth/auth_router.ts b/packages/api/src/routers/auth/auth_router.ts index e9e288e1a..062211539 100644 --- a/packages/api/src/routers/auth/auth_router.ts +++ b/packages/api/src/routers/auth/auth_router.ts @@ -66,20 +66,28 @@ const cookieParams = { maxAge: 365 * 24 * 60 * 60 * 1000, } +const isURLPresent = (input: string): boolean => { + const urlRegex = /(https?:\/\/[^\s]+)/g + return urlRegex.test(input) +} + export const isValidSignupRequest = (obj: any): obj is SignupRequest => { return ( 'email' in obj && obj.email.trim().length > 0 && obj.email.trim().length < 512 && // email must not be empty + !isURLPresent(obj.email) && 'password' in obj && obj.password.length >= 8 && obj.password.trim().length < 512 && // password must be at least 8 characters 'name' in obj && obj.name.trim().length > 0 && obj.name.trim().length < 512 && // name must not be empty + !isURLPresent(obj.name) && 'username' in obj && obj.username.trim().length > 0 && - obj.username.trim().length < 512 // username must not be empty + obj.username.trim().length < 512 && // username must not be empty + !isURLPresent(obj.username) ) } @@ -513,6 +521,7 @@ export function authRouter() { if (recaptchaToken && process.env.RECAPTCHA_CHALLENGE_SECRET_KEY) { const verified = await verifyChallengeRecaptcha(recaptchaToken) + console.log('recaptcha result: ', verified) if (!verified) { return res.redirect( `${env.client.url}/auth/email-signup?errorCodes=UNKNOWN` @@ -520,16 +529,6 @@ export function authRouter() { } } - 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 {