-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working #26
Comments
The problem is that you are adding unless to the function that returns the middleware instead of the middleware itself. With these type of middlewares you can do something like this: const CSURF = require('csurf');
const csurf = CSURF({
cookie: true
});
csrf.unless = unless;
//then
app.use(csrf.unless({
path: [router.get('auth')]
})) |
Same problem. @jfromaniello I don't understand your solution. const unless = require("express-unless")
function checkAuth(req, res, next) {
if (req.session.userName) {
if (req.session.userName) res.locals.userName = req.session.userName
return next()
}
res.status(200).json({ message: "NOT_AUTHENTICATED" })
}
checkAuth.unless = unless
app.use(checkAuth.unless({ path: ["/auth/login"] })) Error:
Code worked fine in 1.0.0 |
@ysageev this is a very old comment for v1.0.0... Its a named export in v2. You need to change to code to do: const { unless } = require("express-unless") Please let me know if that works. |
Thanks. Perfect. Sorry for posting to an old thread. |
csrf.unless = unless;
const csrf = require('csurf');
then add it to middleware...
results in ....
unless is not a function
another example...
handleExpiredTokens.unless({
path: [{
url: '/foo',
methods: ['POST']
}]
});
function handleExpiredTokens(err, req, res, next) {
// stuff
}
handleExpiredTokens.unless = unless;
module.exports = handleExpiredTokens;
handleExpiredTokens runs on every request including POST /foo
The text was updated successfully, but these errors were encountered: