use (LMP)loopback middleware phases
bump loopback-component-passport which uses LMP move custom middlewares to middlewares directory
This commit is contained in:
13
server/middlewares/add-return-to.js
Normal file
13
server/middlewares/add-return-to.js
Normal file
@ -0,0 +1,13 @@
|
||||
export default function addReturnToUrl() {
|
||||
return function(req, res, next) {
|
||||
// Remember original destination before login.
|
||||
var path = req.path.split('/')[1];
|
||||
if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) {
|
||||
return next();
|
||||
} else if (/\/stories\/\w+/i.test(req.path)) {
|
||||
return next();
|
||||
}
|
||||
req.session.returnTo = req.path;
|
||||
next();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user