christmas/middlewares/verifyAuth.js
2020-11-08 16:54:08 -05:00

14 lines
361 B
JavaScript

const config = require('../config')
module.exports = options => {
return (req, res, next) => {
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)
}
}