christmas/middlewares/verifyAuth.js
2020-10-29 23:50:36 -04:00

14 lines
No EOL
372 B
JavaScript

const config = require('../config');
module.exports = options => {
return (req, res, next) => {
options = options ? options : {};
let authed = false
try {
authed = req.isAuthenticated()
} catch {
return res.send('auth fail')
}
if (authed) return next()
res.redirect(options.failureRedirect || config.defaultFailureRedirect)
};
}