0

I have my controller like this

//Get the Helpers var authHelper = require('authHelper'); //Route router.get('/manager', authHelper.checkPerm(req, res, next), function(req, res) { }); 

my authHelper.js

exports.checkPerm = function(req, res, next){ if (req.user) { next(); } else { res.redirect('/sign-in'); } } 

This is the error i am getting

router.get('/manager', authHelper.checkPerm(req, res, next), function(req, res ^ ReferenceError: req is not defined

0

1 Answer 1

1

You are executing the method checkPerm when passing to the route parameter. Remove the parenthesis along with parameters (req, res, next)

Should be like this:

router.get('/manager', authHelper.checkPerm, function(req, res) ... 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.