mirror of
https://github.com/fergalmoran/roboto-promoto.git
synced 2025-12-22 09:37:37 +00:00
26 lines
499 B
JavaScript
26 lines
499 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Custom middleware used by the application
|
|
*/
|
|
module.exports = {
|
|
|
|
/**
|
|
* Protect routes on your api from unauthenticated access
|
|
*/
|
|
auth: function auth(req, res, next) {
|
|
if (req.isAuthenticated()) return next();
|
|
res.send(401);
|
|
},
|
|
|
|
/**
|
|
* Set a cookie for angular so it knows we have an http session
|
|
*/
|
|
setUserCookie: function(req, res, next) {
|
|
if(req.user) {
|
|
res.cookie('user', JSON.stringify(req.user.userInfo));
|
|
}
|
|
next();
|
|
}
|
|
};
|