...
|
...
|
@@ -10,9 +10,6 @@ const LoginService = require('../../apps/passport/models/login-service'); |
|
|
*/
|
|
|
module.exports = () => {
|
|
|
return (req, res, next) => {
|
|
|
req.getUrl = function() {
|
|
|
return req.protocol + '://' + req.get('host') + req.originalUrl;
|
|
|
};
|
|
|
|
|
|
// 从 SESSION 中获取到当前登录用户的 UID
|
|
|
if (req.session && _.isNumber(req.session._LOGIN_UID)) {
|
...
|
...
|
@@ -22,6 +19,7 @@ module.exports = () => { |
|
|
// session 没有读取到的时候,从 cookie 读取 UID
|
|
|
if (!req.user.uid && req.cookies._UID) {
|
|
|
req.user.uid = cookie.getUid(req);
|
|
|
console.log('req.user.uid', req.user.uid);
|
|
|
}
|
|
|
|
|
|
// 从 SESSION 中获得 USERNAME
|
...
|
...
|
@@ -49,7 +47,7 @@ module.exports = () => { |
|
|
|
|
|
return LoginService.syncUserSession(result.data.uid, req, res);
|
|
|
}).then(()=> {
|
|
|
return res.redirect(req.getUrl());
|
|
|
return res.redirect(req.originalUrl);
|
|
|
}).catch(next);
|
|
|
} else {
|
|
|
return next();
|
...
|
...
|
|