|
|
const CaptchaApi = require('./captcha-api');
|
|
|
const logger = global.yoho.logger;
|
|
|
const config = global.yoho.config;
|
|
|
|
|
|
module.exports = class extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
...
|
...
|
@@ -16,8 +17,16 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
_checkUniverse(captcha) {
|
|
|
return captcha === config.UNIVERSAL_CAPTCHA ?
|
|
|
Promise.resolve({code: 200}) :
|
|
|
Promise.reject();
|
|
|
}
|
|
|
|
|
|
check(id, captcha) {
|
|
|
return this.api.check(id, captcha).then((result) => {
|
|
|
return this._checkUniverse(captcha)
|
|
|
.catch(() => this.api.check(id, captcha))
|
|
|
.then((result) => {
|
|
|
if (result.code === 200) {
|
|
|
return {
|
|
|
code: 200,
|
...
|
...
|
|