Authored by htoooth

fix

... ... @@ -98,8 +98,8 @@ app.use((req, res, next) => {
// req.app.locals = _.merge(req.app.locals, {
// pc: {
// login: {
// closePasswordLogin: true
// geetest: {
// validation: true
// }
// }
// });
... ...
... ... @@ -53,46 +53,45 @@ passport.use('local', new LocalStrategy({
let clientIp = req.yoho.clientIp;
let errorLoginKey = 'loginErrorIp:' + clientIp;
let closePasswordLogin = _.get(req.app.locals.pc, 'login.closePasswordLogin', false);
let close = _.get(req.app.locals.pc, 'login.closePasswordLogin', false);
getLoginStat(clientIp).then((times) => {
let errLoginTimes = _.parseInt(times) || 0;
return LoginApi.signin(type, area, username, password, shoppingKey, clientIp, closePasswordLogin).
then((result) => {
if (result.code && (result.code === 200 || result.code === 510) && result.data.uid) {
cache.del(errorLoginKey).catch(() => {});
req.session.type = '';
return LoginApi.signin(type, area, username, password, shoppingKey, clientIp, close).then((result) => {
if (result.code && (result.code === 200 || result.code === 510) && result.data.uid) {
cache.del(errorLoginKey).catch(() => {});
req.session.type = '';
done(null, Object.assign(result.data, {code: result.code}));
} else {
errLoginTimes = errLoginTimes + 1;
cache.set(errorLoginKey, errLoginTimes, 3600).catch(() => {});
if (result.code === 4189) {
return done({
message: `您的密码登录错误次数过多,建议使用手机号码快捷登录或
<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">找回登陆密码</a>!`
});
}
done(null, Object.assign(result.data, {code: result.code}));
// 再次校验
if (errLoginTimes >= 1) {
req.session.type = 'needCaptcha';
done({
message: `您输入的密码及账户名不匹配,
是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
needCaptcha: true,
type: type
});
} else {
errLoginTimes = errLoginTimes + 1;
cache.set(errorLoginKey, errLoginTimes, 3600).catch(() => {});
if (result.code === 4189) {
return done({
message: `您的密码登录错误次数过多,建议使用手机号码快捷登录或
<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">找回登陆密码</a>!`
});
}
// 再次校验
if (errLoginTimes >= 1) {
req.session.type = 'needCaptcha';
done({
message: `您输入的密码及账户名不匹配,
是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
needCaptcha: true,
type: type
});
} else {
done({
message: `您输入的密码及账户名不匹配,
是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
needCaptcha: false
});
}
done({
message: `您输入的密码及账户名不匹配,
是否<a href="${helpers.urlFormat('/passport/back/index')}" target="_blank">忘记密码?</a>`,
needCaptcha: false
});
}
}
});
}).catch(e => {
logger.error('call the signin service fail,', e);
... ...