pdupavillon/express-recaptcha

Express recaptcha on several routes

sigfriedCub1990 opened this issue · 2 comments

This may not be an issue with express-recaptcha itself, but this is driving me crazy, I've made some research on stackoverflow and Google but I couldn't find any solutions on how to do this. What I'm trying to do is:

userController.js

app.get('/user/login', recaptcha.middleware.render,this.login);

login: function (req, res) {
    if (req.user) {
        res.redirect('/admin');
    } else {
        res.render('user/login', {title: 'Login', catpcha: res.recaptcha});
    }
}

registerController.js

app.get('/register', recaptcha.middleware.render, this.register)

register: function(req, res) {
   res.render('index', {title: 'Home', captcha: res.recaptcha})
}

But recaptcha is only rendered on the first route, not the second.
This is a reduced version of my package.json:

   "express": "^4.13.4",
   "express-recaptcha": "^4.0.2"

I've included the packages I thought were needed.

NOTE: I've excluded Recaptcha constructor on purpose

Hi @sigfriedCub1990,
Did you find a way to solve your issue ?

Thanks

Yes @pdupavillon, I'm really sorry, the error was a typo in the variable name. express-recatpcha works like charm, thank you very much.