|
|
/**
|
|
|
* 登录判断
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2016/4/25
|
|
|
* @author: TaoHuang
|
|
|
* @date: 2016/7/15
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
module.exports = (req, res, next) => {
|
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helper;
|
|
|
|
|
|
const required = (req, res, next) => {
|
|
|
req.getUrl = function() {
|
|
|
return req.protocol + '://' + req.get('host') + req.originalUrl;
|
|
|
};
|
|
|
|
|
|
if (_.isEmpty(req.user) || !req.user.uid) {
|
|
|
return res.redirect(helpers.urlFormat('/passport/login', {refer: req.getUrl()}));
|
|
|
}
|
|
|
|
|
|
next();
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
required
|
|
|
}; |
|
|
\ No newline at end of file |
...
|
...
|
|