Authored by 周少峰

Merge branch 'master' into feature/cartAdd

... ... @@ -10,6 +10,7 @@ const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const auth = require(`${global.middleware}/auth`);
const captcha = require('../passport/controllers/captcha');
const ads = require(`${cRoot}/ads`); // 第三方广告平台对接
const robot = require(`${cRoot}/robot-check`); // 机器人检查
... ... @@ -17,7 +18,7 @@ const materialController = require(`${cRoot}/material`);
const activate = require(`${cRoot}/activate`); // 激活点击统计
router.get('/ads', ads.jump);
router.get('/check', robot.index);
router.get('/check', captcha.tryGeetest, robot.index);
router.post('/check', robot.check, robot.isHuman);
router.get('/material', auth, materialController.index);
... ...
... ... @@ -3,7 +3,7 @@
{{> common/path-nav}}
<div class="left-side detail-body" data-id="{{id}}">
{{# header}}
<div class="detail-title">{{title}}</div>
<h1 class="detail-title">{{title}}</h1>
<div class="article-info clearfix">
<div class="article-author">
<div class="author-avatar">
... ...
<div class="ex-reco">
<h1 class="ex-reco-title">精彩推荐</h1>
<h2 class="ex-reco-title">精彩推荐</h2>
<div id="ex-reco-list" class="ex-reco-list">
{{# exRecos}}
<div class="ex-reco-item clearfix">
... ... @@ -16,7 +16,7 @@
{{#unless @root.pc.guang.removeHotTag}}
<div class="hot">
<h1 class="hot-title">热门标签</h1>
<h2 class="hot-title">热门标签</h2>
<div class="hot-tag-list">
{{#hotTags}}
<a class="hot-tag" href="{{url}}" target="_blank">
... ...
... ... @@ -8,6 +8,7 @@
const express = require('express');
const router = express.Router(); // eslint-disable-line
const cRoot = './controllers';
const captcha = require('../passport/controllers/captcha');
const newUserController = require(`${cRoot}/new-user`);
... ... @@ -196,11 +197,11 @@ router.post('/cancelbind/:type', bindController.cancelBind);
// 账号安全
router.get('/account', tabsMiddleware.getCommonHeader, AccountController.index);
router.get('/account/userpwd', tabsMiddleware.getCommonHeader, AccountController.userPwd);
router.get('/account/userpwd', tabsMiddleware.getCommonHeader, captcha.tryGeetest, AccountController.userPwd);
router.get('/account/email', tabsMiddleware.getCommonHeader, AccountController.userEmail);
router.get('/account/email', tabsMiddleware.getCommonHeader, captcha.tryGeetest, AccountController.userEmail);
router.get('/account/mobile', tabsMiddleware.getCommonHeader, AccountController.userMobile);
router.get('/account/mobile', tabsMiddleware.getCommonHeader, captcha.tryGeetest, AccountController.userMobile);
router.post('/account/checkverifycode', tabsMiddleware.getCommonHeader, AccountController.checkVerifyCode);
... ... @@ -244,7 +245,7 @@ router.get('/address/defaultAddress', AddressController.defaultAddress);
// 兑换礼品卡
router.get('/gift', tabsMiddleware.getCommonHeader, giftController.index);
router.get('/gift', tabsMiddleware.getCommonHeader, captcha.tryGeetest, giftController.index);
router.post('/gift/exchange', giftController.exchange);
... ...
... ... @@ -7,23 +7,25 @@ const _ = require('lodash');
const gee = require('./gee-captcha');
const img = require('./img-captcha');
const isGeetest = (req) => {
if (_.get(req.app.locals.pc, 'geetest.validation', false)) {
return req.session.captchaType !== 'img';
}
return false;
};
const requiredAPI = (req, res, next) => {
return (_.get(req.app.locals.pc, 'geetest.validation', false) ?
gee.requiredAPI :
img.requiredAPI)(req, res, next);
return (isGeetest(req) ? gee.requiredAPI : img.requiredAPI)(req, res, next);
};
const generate = (req, res) => {
return (_.get(req.app.locals.pc, 'geetest.validation', false) ?
gee.generate :
img.generate)(req, res);
return (isGeetest(req) ? gee.generate : img.generate)(req, res);
};
// 端到端检查
const checkAPI = (req, res) => {
return (_.get(req.app.locals.pc, 'geetest.validation', false) ?
gee.checkAPI :
img.checkAPI)(req, res);
return (isGeetest(req) ? gee.checkAPI : img.checkAPI)(req, res);
};
const passwordRequired = (req, res, next) => {
... ... @@ -34,9 +36,20 @@ const passwordRequired = (req, res, next) => {
}
};
const tryGeetest = (req, res, next) => {
if (isGeetest(req)) {
req.app.locals.geetest = true;
} else {
req.app.locals.geetest = false;
}
next();
};
module.exports = {
requiredAPI,
generate,
checkAPI,
passwordRequired
passwordRequired,
tryGeetest
};
... ...
... ... @@ -9,7 +9,6 @@ const Geetest = require('../models/captcha-gee-service');
const config = global.yoho.config;
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
const CAPTCHA = config.UNIVERSAL_CAPTCHA;
... ... @@ -23,17 +22,25 @@ var pcGeetest = new Geetest({
geetest_key: config.gee_captcha.key
});
const generate = (req, res) => {
const generate = (req, res, next) => {
pcGeetest.register(function(err, data) {
if (err) {
return;
}
if (!data.success) {
res.send(data);
req.session.captchaType = 'img';
res.json({
code: 501,
data: data
});
} else {
// 正常模式
res.send(data);
req.session.captchaType = 'geetest';
res.send({
code: 200,
data: data
});
}
});
};
... ...
... ... @@ -3,10 +3,8 @@
*/
'use strict';
const _ = require('lodash');
const captchaService = require('../models/captcha-img-service');
const helpers = global.yoho.helpers;
const CAPTCHA = global.yoho.config.UNIVERSAL_CAPTCHA;
const request = require('request');
const logger = global.yoho.logger;
... ...
... ... @@ -20,7 +20,7 @@ const auth = require(`${global.middleware}/auth`);
const router = express.Router(); // eslint-disable-line
// 兼容老的路由
router.get('/signin.html', login.common.beforeLogin, login.local.loginPage);
router.get('/signin.html', login.common.beforeLogin, captcha.tryGeetest, login.local.loginPage);
router.get('/reg.html', reg.index);
router.get('/logout.html', login.local.logout);
... ... @@ -34,7 +34,7 @@ router.post('/passport/login/sms/checkuser', login.local.sms.checkUser); // 短
router.post('/passport/login/qrcode/refresh', login.local.qrcode.refresh); // 刷新二维码
router.post('/passport/login/qrcode/check', login.local.qrcode.check); // 验证二维码的状态
router.get('/passport/login', login.common.beforeLogin, login.local.loginPage);
router.get('/passport/login', login.common.beforeLogin, captcha.tryGeetest, login.local.loginPage);
router.post('/passport/login/auth', captcha.passwordRequired, login.local.login);
router.get('/passport/logout', login.local.logout);
... ... @@ -94,7 +94,7 @@ router.post('/passport/cert/relateMobile', auth, cert.relateMobile);
/**
* 注册页面路由
*/
router.get('/passport/reg/index', reg.index);
router.get('/passport/reg/index', captcha.tryGeetest, reg.index);
// NOTE: 该接口的存在只是为了兼容前端 ajax 请求
router.post('/passport/reg/checkmobile', reg.fakeCheckMobile);
... ... @@ -117,7 +117,7 @@ router.get('/passport/reg/success', reg.success);
* 找回密码首页信息
*/
// 找回密码首页
router.get('/passport/back/index', back.index);
router.get('/passport/back/index', captcha.tryGeetest, back.index);
// 验证输入是否正确
router.post('/passport/back/authcode',
... ...
... ... @@ -91,7 +91,7 @@
{{# sortIntro}}
<div class="sort-intro clearfix">
<div class="texts pull-left">
<p class="name">{{name}}</p>
<h1 class="name">{{name}}</h1>
<p class="en-name">{{enName}}</p>
<p class="desc">{{{description}}}</p>
<div class="key-entry">
... ...
... ... @@ -65,12 +65,12 @@
</div>
</div>
<div class="pull-right infos">
<p class="name">
<h1 class="name">
{{#if marketTip}}
<span class="red">{{marketTip}}</span>
{{/if}}
{{name}}
</p>
</h1>
{{#if saleTip}}
<span class="sale-tip">{{saleTip}}</span>
... ...
... ... @@ -17,15 +17,15 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
// test3
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// prod
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
//singleApi: 'http://single.yoho.cn/',
//api: 'http://api.yoho.cn/',
//service: 'http://service.yoho.cn/',
//
// gray
// singleApi: 'http://single.gray.yohops.com/',
// api: 'http://api.gray.yohops.com/',
... ...
... ... @@ -2,11 +2,11 @@
<div class="simple-header">
<div class="header-inner clearfix">
{{# logo}}
<h1 class="logo">
<h2 class="logo">
<a href="{{url}}">
<img src="{{image2 img}}" alt="">
</a>
</h1>
</h2>
{{/ logo}}
<ul class="header-tool clearfix">
{{# tool}}
... ...
... ... @@ -373,11 +373,11 @@
</a>
<div class="download-app-box">
<div class="qr-img"></div>
<h3 class="qr-words">扫描二维码</h3>
<h3 class="qr-words">下载YohoBuy手机端</h3>
<h3 class="qr-more">
<h5 class="qr-words">扫描二维码</h5>
<h5 class="qr-words">下载YohoBuy手机端</h5>
<h5 class="qr-more">
<a href="//www.yohobuy.com/download/app" target="_blank">更多客户端下载</a>
</h3>
</h5>
</div>
</div>
<div class="layer-box return-top">
... ...
{{#if @root.pc.geetest.validation}}
{{#if @root.geetest}}
<script>window._geeCaptcha = true;</script>
<script src="http://static.geetest.com/static/tools/gt.js"></script>
{{/if}}
... ...
... ... @@ -57,11 +57,11 @@
<a href="//www.yohobuy.com/download/app">手机版</a>
<div class="download-app-box">
<div class="qr-img"></div>
<h3 class="qr-words">扫描二维码</h3>
<h3 class="qr-words">下载有货手机客户端</h3>
<h3 class="qr-more">
<h5 class="qr-words">扫描二维码</h5>
<h5 class="qr-words">下载有货手机客户端</h5>
<h5 class="qr-more">
<a href="//www.yohobuy.com/download/app">更多客户端下载</a>
</h3>
</h5>
</div>
</li>
</ul>
... ... @@ -150,7 +150,7 @@
<dl class="hide-list hide">
{{# thirdNav}}
<dt>
<h1 class=""><a href="{{link}}">{{title}}</a></h1>
<h3 class=""><a href="{{link}}">{{title}}</a></h3>
</dt>
{{#brandItems}}
<dd>
... ... @@ -189,9 +189,9 @@
<div class="user-name">
<a href="//www.yohobuy.com/home?t=\{{random}}">\{{profileName}}</a>
</div>
<h3 class="user-level">
<h4 class="user-level">
VIP: <span>\{{curTitle}}</span>
</h3>
</h4>
\{{#unless vip3}}
<div class="level-detail">
<div class="level-view-bar">
... ...
{
"name": "yohobuy-node",
"version": "5.5.11",
"version": "5.5.13",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -62,7 +62,7 @@
"gulp-ftp": "^1.1.0",
"gulp-postcss": "^6.1.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^2.0.0-alpha",
"gulp-sourcemaps": "2.0.0-alpha",
"gulp-util": "^3.0.7",
"handlebars-loader": "^1.4.0",
"husky": "^0.11.4",
... ...
... ... @@ -143,7 +143,7 @@ function setTopBanner(data) {
} else {
topbanner = '<div class="yoho-notice">' +
'<div class="notice-container center-content">' +
'<h1 class="notice-title">关于系统升级的公告</h1>' +
'<h4 class="notice-title">关于系统升级的公告</h4>' +
'<div class="notice-content">' +
'<p class="tips">尊敬的顾客:</p>' +
'<p class="detail">您好!为了向您提供更优质的服务,目前系统正在升级,请耐心等待。</p>' +
... ...
... ... @@ -32,12 +32,17 @@ GeeCaptcha.prototype = {
init: function() {
var _this = this;
$.get(_this.initURI + '?t=' + $.now()).then(function(data) {
$.get(_this.initURI + '?t=' + $.now()).then(function(result) {
if (result.code === 501) {
window.location.reload(true);
return;
}
initGeetest && initGeetest({ // eslint-disable-line
gt: data.gt,
challenge: data.challenge,
gt: result.data.gt,
challenge: result.data.challenge,
product: 'float', // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
offline: !data.success // 表示用户后台检测极验服务器是否宕机,一般不需要关注
offline: !result.data.success // 表示用户后台检测极验服务器是否宕机,一般不需要关注
}, $.proxy(_this.initCallback, _this));
});
... ... @@ -80,7 +85,7 @@ GeeCaptcha.prototype = {
var _this = this;
return $.sleep(500).then(function() {
_this._captchObj.refresh();
_this._captchObj && _this._captchObj.refresh();
});
},
... ...
... ... @@ -107,7 +107,7 @@ exports.setPager = (total, params)=>{
}, {num: '...'}, pages);
} else {
pages = _.concat({
url: '?page=1',
url: joinUrl(Object.assign(params, {page: 1})),
num: 1
}, pages);
}
... ...