mirror of
https://github.com/luxfi/pics.git
synced 2026-10-30 15:22:15 +00:00
14 lines
321 B
JavaScript
14 lines
321 B
JavaScript
'use strict';
|
|
|
|
module.exports = async (req, res, next) => {
|
|
if (res.locals.user) {
|
|
return next();
|
|
}
|
|
let goto;
|
|
if (req.method === 'GET' && req.path) {
|
|
//coming from a GET page isLoggedIn middleware check
|
|
goto = encodeURIComponent(req.path);
|
|
}
|
|
return res.redirect(`/login.html${goto ? '?goto='+goto : ''}`);
|
|
};
|