Authored by yyq

fix captcha

... ... @@ -15,7 +15,7 @@ const isGeetest = (req) => {
};
function required(req, res, next) {
img.trySwitch(req).then(() => {
img.trySwitch(req, res).then(() => {
if (req.session.captcha.type === CAPTCHA_TYPE.image && req.session.captcha.value === CAPTCHA_SWITCH.off) {
const captcha = {
type: CAPTCHA_TYPE.geetest,
... ... @@ -23,7 +23,7 @@ function required(req, res, next) {
};
req.session.captcha = captcha;
res.app.locals.captcha = captcha;
res.locals.captcha = captcha;
}
next();
}).catch(next);
... ... @@ -62,7 +62,7 @@ const geeOnly = function(req, res, next) {
};
req.session.captcha = captcha;
res.app.locals.captcha = captcha;
res.locals.captcha = captcha;
next();
};
... ...
... ... @@ -56,7 +56,7 @@ const checkAPI = (req, res, next) => {
}).catch(next);
};
const trySwitch = (req) => {
const trySwitch = (req, res) => {
return req.ctx(CaptchaServiceModel).try().then((result) => {
const captcha = {
type: CAPTCHA_TYPE.image,
... ... @@ -64,7 +64,7 @@ const trySwitch = (req) => {
};
req.session.captcha = captcha;
req.app.locals.captcha = captcha;
res.locals.captcha = captcha;
});
};
... ...