Authored by htoooth

add user auth

... ... @@ -16,12 +16,7 @@ const getAreaDataAsync = () => {
}).then(result => {
result.data = result.data.map(value => {
value.areaCode = `+${value.area}`;
if (value.areaCode === '+86') {
value.selected = true;
} else {
value.selected = false;
}
value.areaCode = value.areaCode === '+86';
delete value.area;
return value;
... ...
/**
* 登录判断
* @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
... ...