Authored by 郭成尧

conflict-handle

... ... @@ -36,6 +36,7 @@ passport.use(new LocalStrategy({
let area = req.body.areaCode || '86';
let clientIp = req.yoho.clientIp || '';
let isSkip = req.body.isskip;
let from = req.cookies.from || 'yohobuy';
if (isNaN(parseInt(area, 0)) || _.isEmpty(username) || _.isEmpty(password)) {
logger.info(`【Passport Loginbad params, area:${area} account:${username} password:${password}`);
... ... @@ -66,7 +67,7 @@ passport.use(new LocalStrategy({
let shoppingKey = cookie.getShoppingKey(req);
AuthHelper.signinAes(area, username, password, shoppingKey, clientIp, isSkip).then((result) => {
AuthHelper.signinAes(area, username, password, shoppingKey, clientIp, isSkip, from).then((result) => {
if (result.code && result.code === 200 && result.data.uid) {
done(null, result.data);
} else if (result.code && result.code === 4189) {
... ...
... ... @@ -149,6 +149,16 @@ const common = {
refer && !/signin|login|passport/.test(refer) && res.cookie('refer', encodeURI(refer), {
domain: 'yohobuy.com'
});
let from = req.query.from;
if (from) {
res.cookie('from', from, {
domain: 'yohobuy.com',
expires: new Date(Date.now() + 10 * 60 * 1000)
});
}
if (req.yoho.isApp) {
return next({
code: 401,
... ...
... ... @@ -85,6 +85,7 @@ class Reg {
let inviteCode = req.body.inviteCode || '';
let isFromMy = _.get(req.session, 'phoneReg.isFromMy', '0');
let token = req.body.token;
let from = req.cookies.from || 'yohobuy';
// 购物车key
let shoppingKey = cookie.getShoppingKey(req);
... ... @@ -121,7 +122,7 @@ class Reg {
}
let regMobileAesResult = yield RegService.regMobileAes(area, mobile, password,
shoppingKey, smsCode, inviteCode, isFromMy);
shoppingKey, smsCode, inviteCode, isFromMy, from);
if (regMobileAesResult.code !== 200 || !regMobileAesResult.data ||
!regMobileAesResult.data.uid) {
... ...
... ... @@ -99,7 +99,7 @@ class SmsLogin {
// 验证
if ([area, mobile].some(val => val === '')) {
return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'}));
return em.emit('reject', Object.assign(errorData, { message: '请填写手机号' }));
}
// congratulation~~
... ... @@ -201,6 +201,7 @@ class SmsLogin {
const mobile = _.get(req.session, 'smsLogin.mobile', '');
const area = _.get(req.session, 'smsLogin.area', '');
const shopping_key = cookie.getShoppingKey(req); // eslint-disable-line
let from = req.cookies.from || 'yohobuy';
if (!mobile || !area) {
res.json({
... ... @@ -261,7 +262,8 @@ class SmsLogin {
profile: mobile,
code: r2.data.code,
area,
shopping_key
shopping_key,
from
})
.then(info => {
if (info.code !== 200) {
... ... @@ -309,6 +311,7 @@ class SmsLogin {
let password = (req.body.password || '').trim();
let registerCode = req.body.registerCode || '';
let clientIp = req.yoho.clientIp || '';
let from = req.cookies.from || 'yohobuy';
if (!password) {
data.message = PASSWORD_REQUIRED;
... ... @@ -331,7 +334,8 @@ class SmsLogin {
// 验证注册的标识码是否有效
let resultCopy = null;
RegService.regMobileAes(area, mobile, password, shoppingKey, registerCode, null, clientIp).then(result => {
RegService.regMobileAes(area, mobile, password,
shoppingKey, registerCode, null, clientIp, from).then(result => {
if (!result.code || result.code !== 200) {
return res.send(result);
}
... ...
... ... @@ -11,6 +11,7 @@ const md5 = require('yoho-md5');
const moment = require('moment');
const querystring = require('querystring');
const thirdAccount = require('../data/third-account.json');
const FROM = require('../../../config/from');
class Auth {
... ... @@ -29,13 +30,14 @@ class Auth {
return api.post('', param);
}
static signinAes(area, profile, password, shoppingKey, ip, isSkip) {
static signinAes(area, profile, password, shoppingKey, ip, isSkip, from) {
let param = {
method: 'sesame.flowering.higher',
area: area,
profile: profile,
password: aes.aesPwd(password),
isSkip: isSkip ? isSkip : 'N'
isSkip: isSkip ? isSkip : 'N',
business_line: FROM[from]
};
if (shoppingKey) {
... ...
/* eslint no-unused-vars: ["error", { "args": "none" }] */
'use strict';
const API = global.yoho.API;
const FROM = require('../../../config/from');
class PhoneService {
// 校验 手机 是否 已注册
... ... @@ -21,7 +22,8 @@ class PhoneService {
profile: param.profile,
area: param.area,
code: param.code,
shopping_key: param.shopping_key
shopping_key: param.shopping_key,
business_line: FROM[param.from]
});
}
... ...
... ... @@ -9,6 +9,7 @@
const api = global.yoho.API;
const aes = require('./aes-pwd');
const FROM = require('../../../config/from');
const RegService = {
getAreaData() {
... ... @@ -96,7 +97,7 @@ const RegService = {
return api.post('', params);
},
regMobileAes(area, mobile, password, shoppingKey, smsCode, inviteCode, isFromMy, clientIp) {
regMobileAes(area, mobile, password, shoppingKey, smsCode, inviteCode, isFromMy, clientIp, from) {
isFromMy = isFromMy || '0';
let params = {
... ... @@ -106,7 +107,8 @@ const RegService = {
password: aes.aesPwd(password),
verifyCode: smsCode,
inviteCode: inviteCode,
isFromMy
isFromMy,
business_line: FROM[from]
};
if (shoppingKey) {
... ...
/**
* 登录来源
*/
module.exports = {
yohobuy: 'Yoho!Buy',
yohomars: 'mars',
yohocoffee: 'Yo!Coffee',
yohogreen: 'Yo!Green'
};
... ...