Initial Commit
This commit is contained in:
commit
f54d97e4a9
30 changed files with 2532 additions and 0 deletions
8
middlewares/locals.js
Normal file
8
middlewares/locals.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
const config = require('../config');
|
||||
module.exports = (req, res, next) => {
|
||||
res.locals.successes = req.flash('success');
|
||||
res.locals.errors = req.flash('error');
|
||||
res.locals.config = config;
|
||||
res.locals.req = req;
|
||||
next();
|
||||
};
|
11
middlewares/verifyAuth.js
Normal file
11
middlewares/verifyAuth.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const config = require('../config');
|
||||
module.exports = options => {
|
||||
return (req, res, next) => {
|
||||
options = options ? options : {};
|
||||
if (req.isAuthenticated()) {
|
||||
next();
|
||||
} else {
|
||||
res.redirect(options.failureRedirect || config.defaultFailureRedirect);
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue