Redirect to normal page on invalid referral code
We don't want to be misleading people with random referral links that don't actually apply!
This commit is contained in:
parent
d9785d601e
commit
11cefdada0
1 changed files with 11 additions and 0 deletions
|
@ -224,6 +224,10 @@ let homeView = async (req, res) => {
|
|||
referrer = pledge.get('anonymous') ? 'Anonymous' : pledge.get('name')
|
||||
} catch(e) {
|
||||
if (DEBUG) console.debug(`Skipping referral ${req.params.referralCode} because not found: ${e}`)
|
||||
|
||||
// if the referrer doesn't exist, send people to the normal homepage!
|
||||
res.redirect('/')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,6 +691,13 @@ The Snipette Team`
|
|||
})
|
||||
|
||||
router.get('/thanks', async (req, res) => {
|
||||
// validate referral code
|
||||
if (!!req.query.ref && !await findReferrer(req.query.ref)) {
|
||||
if (DEBUG) console.debug(`Invalid referral: redirecting to normal page`)
|
||||
res.redirect('/thanks')
|
||||
return
|
||||
}
|
||||
|
||||
let output = await twing.render('thanks.htm.twig', {
|
||||
referral_code: req.query.ref,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue