Authored by 郭成尧

smart-forward-go-ok

... ... @@ -37,6 +37,8 @@ passport.use(new LocalStrategy({
let clientIp = req.yoho.clientIp || '';
let isSkip = req.body.isskip;
let from = req.cookies.from || 'yohobuy';
let udid = req.sessionID;
let captcha = req.body.captcha;
if (isNaN(parseInt(area, 0)) || _.isEmpty(username) || _.isEmpty(password)) {
logger.info(`【Passport Loginbad params, area:${area} account:${username} password:${password}`);
... ... @@ -59,15 +61,23 @@ passport.use(new LocalStrategy({
return done('登录账号格式错误', null);
}
// let expire = req.cookies['LE' + md5('_LOGIN_EXPIRE')];
// if (_.isEmpty(expire) || expire < (new Date()).getTime() / 1000) {
// return done('页面停留时间过长,请刷新页面', null);
// }
let shoppingKey = cookie.getShoppingKey(req);
req.ctx(AuthHelperModel).signinAes(area, username, password, shoppingKey, clientIp, isSkip, from).then((result) => {
if (req.body.geetest_challenge) {
captcha = req.body.geetest_challenge; // TODO 使用极验证传特殊的值
}
req.ctx(AuthHelperModel).signinAes({
area,
profile: username,
password,
shoppingKey,
ip: clientIp,
isSkip,
from,
udid,
degrees: captcha
}).then((result) => {
if (result.code && result.code === 200 && result.data.uid) {
done(null, result.data);
} else if (result.code && result.code === 4189) {
... ...
... ... @@ -4,7 +4,6 @@ const aes = require('./aes-pwd');
const authcode = require('../../../utils/authcode');
const logger = global.yoho.logger;
const sign = global.yoho.sign;
const api = global.yoho.API;
const uuid = require('uuid');
const url = require('url');
const md5 = require('yoho-md5');
... ... @@ -12,6 +11,7 @@ const moment = require('moment');
const querystring = require('querystring');
const thirdAccount = require('../data/third-account.json');
const FROM = require('../../../config/from');
const PAGE = 'H5';
class AuthModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -30,31 +30,30 @@ class AuthModel extends global.yoho.BaseModel {
param.shopping_key = shoppingKey;
}
return api.post('', param);
return this.post({data: param});
}
signinAes(area, profile, password, shoppingKey, ip, isSkip, from) {
signinAes(params) {
let param = {
method: 'sesame.flowering.higher',
area: area,
profile: profile,
password: aes.aesPwd(password),
isSkip: isSkip ? isSkip : 'N',
business_line: FROM[from].business_line
method: 'smart.forward.go',
area: params.area,
profile: params.profile,
password: aes.aesPwd(params.password),
isSkip: params.isSkip ? params.isSkip : 'N',
business_line: FROM[params.from].business_line,
udid: params.udid,
fromPage: PAGE,
degrees: params.captcha
};
if (shoppingKey) {
param.shopping_key = shoppingKey;
if (params.shoppingKey) {
param.shopping_key = params.shoppingKey;
}
logger.info(`${profile}, login from ${ip}`);
logger.info(`${params.profile}, login from ${params.ip}`);
return api.post('', param, {
headers: {
'user-agent': 'yoho/nodejs',
'X-YOHO-IP': ip,
'X-Forwarded-For': ip
}
return this.post({
data: param
});
}
... ... @@ -71,7 +70,7 @@ class AuthModel extends global.yoho.BaseModel {
param.shopping_key = shoppingKey;
}
return api.get('', param);
return this.get({data: param});
}
profile(uid) {
... ... @@ -80,7 +79,7 @@ class AuthModel extends global.yoho.BaseModel {
method: 'app.passport.profile'
};
return api.get('', param);
return this.get({data: param});
}
thirdSign(params, clientSecret) {
... ...
... ... @@ -90,18 +90,14 @@ class Login {
isskip: window.queryString.isskip
};
if ($captcha.data('userverify')) {
validate.getResults().then((result) => {
this.view.loginBtn.text('正在登录...').addClass('disable');
validate.getResults().then((result) => {
this.view.loginBtn.text('正在登录...').addClass('disable');
$.extend(params, result);
$.extend(params, result);
// auth
this.loginAuth(params, acc);
}, () => {});
} else {
// auth
this.loginAuth(params, acc);
}
}, () => {});
} else {
showErrTip('账号或密码有错误,请重新输入');
this.view.loginBtn.text('登录').removeClass('disable');
... ...