auth.js
366 Bytes
/**
* 登录判断
* @author: leo<qi.li@yoho.cn>
* @date: 2017/6/23
*/
'use strict';
const _ = require('lodash');
module.exports = (req, res, next) => {
const userId = _.get(req.session, 'user.id', 0);
if (!userId) {
return res.json({
code: 401,
message: '抱歉,您暂未登录!'
});
}
next();
};