Authored by 陈峰

merge

const Geetest = require('geetest');
const captcha = new Geetest({
geetest_id: 'bce95d796bc3058615fdf2ec2c0aef29',
geetest_key: '124c41d3a22aa48f36ae3cd609c51db5'
});
const geetest = {
register(req, res, next) {
captcha.register().then(function(data) {
// data 为一个对象,包含 gt, challenge, success, new_captcha 字段
// success 为 1 表示正常模式,为 0 表示宕机模式(failback, fallback)
// var body = {
// gt: data.geetest_id,
// challenge: data.challenge,
// success: data.success
// };
res.send(data);
}).catch(next);
},
validate(req, res, next) {
captcha.validate({
challenge: 'xxx',
validate: 'xxx',
seccode: 'xxx'
}).then(function(success) {
if (success) {
return next();
}
return res.send(403, {
code: 403,
message: 'captcha error'
});
});
}
};
module.exports = geetest;
... ...
... ... @@ -19,10 +19,15 @@ const smsLogin = require(cRoot + '/sms');
const update = require(cRoot + '/update');
const agreement = require(cRoot + '/app-agreement');
const geetest = require(cRoot + '/geetest');
const router = express.Router(); // eslint-disable-line
router.get('/passport/geetest/register', geetest.register);
// 兼容老的路由
router.get('/signin.html', login.common.beforeLogin, login.local.loginPage);
// router.get('/signin.html', login.common.beforeLogin, smsLogin.loginPage);
router.get('/reg.html', disableBFCahce, reg.index);
router.get('/login.html', login.common.beforeLogin, login.local.international);
... ... @@ -34,6 +39,8 @@ router.get('/passport/signout/index', login.local.logout);
// 登录页面
router.get('/passport/login', login.common.beforeLogin, login.local.loginPage);
router.get('/passport/international', login.common.beforeLogin, login.local.international);
// 本地登录
... ...
... ... @@ -31,6 +31,7 @@
"cookie-parser": "^1.4.3",
"express": "^4.14.1",
"feed": "^0.3.1",
"geetest": "^4.1.1",
"lodash": "^4.17.4",
"md5": "^2.1.0",
"memory-cache": "^0.1.6",
... ...