Authored by ccbikai

Merge branch 'feature/passport' into release/1.0

... ... @@ -75,7 +75,7 @@ const bind = {
});
},
bindCheck: (req, res) => {
bindCheck: (req, res, next) => {
let phoneNum = req.body.phoneNum;
let openId = req.body.openId;
let areaCode = req.body.areaCode || '86';
... ... @@ -105,7 +105,7 @@ const bind = {
}
res.json(data);
});
}).catch(next);
} else {
res.json({
code: 400,
... ... @@ -115,7 +115,7 @@ const bind = {
}
},
sendBindMsg: (req, res) => {
sendBindMsg: (req, res, next) => {
let phoneNum = req.body.phoneNum;
let areaCode = req.body.areaCode;
... ... @@ -126,13 +126,13 @@ const bind = {
} else {
res.json({ code: 400, message: '', data: '' });
}
});
}).catch(next);
} else {
res.json({ code: 400, message: '', data: '' });
}
},
checkBindMsg: (req, res) => {
checkBindMsg: (req, res, next) => {
let phoneNum = req.body.phoneNum;
let code = req.body.code;
let areaCode = req.body.areaCode;
... ... @@ -144,13 +144,13 @@ const bind = {
} else {
res.json({ code: 400, message: '', data: '' });
}
});
}).catch(next);
} else {
res.json({ code: 400, message: '', data: '' });
}
},
bindMobile: (req, res) => {
bindMobile: (req, res, next) => {
let phoneNum = req.body.phoneNum;
let openId = req.body.openId;
let areaCode = req.body.areaCode || '86';
... ... @@ -176,13 +176,13 @@ const bind = {
return result;
}).then(result => {
res.json(result);
});
}).catch(next);
} else {
res.json({ code: 400, message: '', data: '' });
}
},
relateMobile: (req, res) => {
relateMobile: (req, res, next) => {
let phoneNum = req.body.phoneNum;
let openId = req.body.openId;
let areaCode = req.body.areaCode || '86';
... ... @@ -206,7 +206,7 @@ const bind = {
return result;
}).then(result => {
res.json(result);
});
}).catch(next);
} else {
res.json({ code: 400, message: '', data: '' });
}
... ... @@ -223,20 +223,20 @@ const bind = {
});
},
changeCheck: (req, res) => {
changeCheck: (req, res, next) => {
let phoneNum = req.body.phoneNum;
let areaCode = req.body.areaCode;
if (_.isNumber(parseInt(phoneNum, 0)) && areaCode) {
BindService.changeCheck(phoneNum, areaCode).then(result => {
res.json(result);
});
}).catch(next);
} else {
res.json({ code: 400, message: '', data: '' });
}
},
changeMobile: (req, res) => {
changeMobile: (req, res, next) => {
let uid = req.user.uid;
let phoneNum = req.body.phoneNum;
let areaCode = req.body.areaCode;
... ... @@ -245,7 +245,7 @@ const bind = {
if (_.isNumber(parseInt(phoneNum, 0)) && uid && areaCode && code) {
BindService.changeMobile(uid, phoneNum, areaCode, code).then(result => {
res.json(result);
});
}).catch(next);
} else {
res.json({ code: 400, message: '', data: '' });
}
... ...
... ... @@ -59,11 +59,11 @@ class Auth {
domain: 'yohobuy.com'
});
}
req.session._TOKEN = token; // esline-disable-line
req.session._LOGIN_UID = uid; // esline-disable-line
req.session._TOKEN = token;
req.session._LOGIN_UID = uid;
res.cookie('_TOKEN', token, {
domain: 'yohobuy.com'
}); // esline-disable-line
});
});
}
}
... ...
... ... @@ -10,9 +10,8 @@
const API = require(`${global.library}/api`).API;
const api = new API();
class RegService {
static bindCheck(mobile, openId, sourceType, area) {
const RegService = {
bindCheck(mobile, openId, sourceType, area) {
let params = {
method: 'app.passport.signCheck',
area: area,
... ... @@ -22,9 +21,8 @@ class RegService {
};
return api.get('', params);
}
static sendBindMsg(area, mobile) {
},
sendBindMsg(area, mobile) {
let params = {
method: 'app.passport.smsbind',
mobile: mobile,
... ... @@ -32,18 +30,16 @@ class RegService {
};
return api.get('', params);
}
static checkBindCode(area, mobile, code) {
},
checkBindCode(area, mobile, code) {
return api.get('', {
method: 'app.register.validRegCode',
mobile: mobile,
area: area,
code: code
});
}
static bindMobile(openId, sourceType, mobile, area, password, nickname) {
},
bindMobile(openId, sourceType, mobile, area, password, nickname) {
let params = {
method: 'app.passport.bind',
mobile: mobile,
... ... @@ -61,9 +57,8 @@ class RegService {
}
return api.get('', params);
}
static relateMobile(openId, sourceType, mobile, area) {
},
relateMobile(openId, sourceType, mobile, area) {
return api.get('', {
method: 'app.passport.relateMobile',
mobile: mobile,
... ... @@ -71,17 +66,15 @@ class RegService {
source_type: sourceType,
area: area
});
}
static changeCheck(mobile, area) {
},
changeCheck(mobile, area) {
return api.get('', {
method: 'app.passport.changeCheck',
mobile: mobile,
area: area
});
}
static changeMobile(uid, mobile, area, code) {
},
changeMobile(uid, mobile, area, code) {
return api.get('', {
method: 'app.passport.changeMobile',
mobile: mobile,
... ... @@ -90,6 +83,6 @@ class RegService {
area: area
});
}
}
};
module.exports = RegService;
... ...
... ... @@ -16,7 +16,7 @@ const ALIPAY_URL = 'https://mapi.alipay.com/gateway.do';
const defaultOptions = {
service: 'alipay.auth.authorize',
_input_charset: 'utf-8', // esline-disable-line
_input_charset: 'utf-8',
sign_type: 'MD5',
target_service: 'user.auth.quick.login'
};
... ...
... ... @@ -10,9 +10,8 @@
const API = require(`${global.library}/api`).API;
const api = new API();
class RegService {
static getAreaData() {
const RegService = {
getAreaData() {
return [
{
areaCode: '+61',
... ... @@ -63,9 +62,8 @@ class RegService {
selected: false,
name: '中国香港'
}];
}
static sendCodeToMobile(area, mobile) {
},
sendCodeToMobile(area, mobile) {
let params = {
method: 'app.register.sendRegCodeToMobile',
area: area,
... ... @@ -73,9 +71,8 @@ class RegService {
};
return api.post('', params);
}
static validMobileCode(area, mobile, code) {
},
validMobileCode(area, mobile, code) {
let params = {
method: 'app.register.validRegCode',
area: area,
... ... @@ -84,9 +81,8 @@ class RegService {
};
return api.post('', params);
}
static regMobile(area, mobile, password, shoppingKey) {
},
regMobile(area, mobile, password, shoppingKey) {
let params = {
method: 'app.passport.register',
area: area,
... ... @@ -95,11 +91,11 @@ class RegService {
};
if (shoppingKey) {
params.shopping_key = shoppingKey; // esline-disable-line
params.shopping_key = shoppingKey;
}
return api.post('', params);
}
}
};
module.exports = RegService;
... ...
... ... @@ -286,6 +286,9 @@ exports.verifyMobile = (phone) => {
return /^1[3|4|5|8|7][0-9]{9}$/.test(phone);
};
/**
* 验证密码规则
*/
exports.verifyPassword = (password) => {
if (!password) {
return false;
... ...
This diff could not be displayed because it is too large.