auth.js
697 Bytes
/**
* controller 入口
* @author: feng.chen<feng.chen@yoho.cn>
* @date: 2017/04/13
*/
module.exports = (req, res, next) => {
if (!req.user.uid) {
return res.status(401).json({
code: 401,
message: '抱歉,您暂未登录!',
data: {
refer: '/login'
}
});
}
if (req.session.needUpdate &&
req.path !== '/Api/erp/getPurview' &&
req.path !== '/Api/erp/update') {
return res.status(403).json({
code: 403,
message: '抱歉,您暂未修改密码!',
data: {
refer: '/password'
}
});
}
next();
};