mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Update the isValidSignUp to check for URLs
This commit is contained in:
parent
442475d684
commit
9a159084c8
1 changed files with 10 additions and 11 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue