From e8f4a74cc276facc6c2a8f7c488a8683a21ae87c Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Tue, 15 Nov 2022 21:03:35 +0800 Subject: [PATCH] fix: captcha required error --- .../uni-id-co/module/account/reset-pwd-by-email.js | 5 +++++ .../uni-id-co/module/account/reset-pwd-by-sms.js | 5 +++++ .../cloudfunctions/uni-id-co/module/login/login-by-sms.js | 8 ++++++++ .../cloudfunctions/uni-id-co/module/login/login.js | 5 +++++ .../uni-id-co/module/relate/bind-mobile-by-sms.js | 8 ++++++++ 5 files changed, 31 insertions(+) diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js index 7b6ae91..c6aa924 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js @@ -52,6 +52,11 @@ module.exports = async function (params = {}) { type: LOG_TYPE.RESET_PWD_BY_EMAIL }) if (needCaptcha) { + if (!captcha) { + throw { + errCode: ERROR.CAPTCHA_REQUIRED + } + } await verifyCaptcha.call(this, { captcha, scene: CAPTCHA_SCENE.RESET_PWD_BY_EMAIL diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js index 05e68bf..cda821a 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js @@ -52,6 +52,11 @@ module.exports = async function (params = {}) { type: LOG_TYPE.RESET_PWD_BY_SMS }) if (needCaptcha) { + if (!captcha) { + throw { + errCode: ERROR.CAPTCHA_REQUIRED + } + } await verifyCaptcha.call(this, { captcha, scene: CAPTCHA_SCENE.RESET_PWD_BY_SMS diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-sms.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-sms.js index 8f9aeaf..419c7cc 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-sms.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-sms.js @@ -14,6 +14,9 @@ const { SMS_SCENE, LOG_TYPE } = require('../../common/constants') +const { + ERROR +} = require('../../common/error') /** * 短信验证码登录 @@ -51,6 +54,11 @@ module.exports = async function (params = {}) { }) if (needCaptcha) { + if (!captcha) { + throw { + errCode: ERROR.CAPTCHA_REQUIRED + } + } await verifyCaptcha.call(this, { captcha, scene: CAPTCHA_SCENE.LOGIN_BY_SMS diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login.js index 97e9cfe..396ec80 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login.js @@ -71,6 +71,11 @@ module.exports = async function (params = {}) { email }) if (needCaptcha) { + if (!captcha) { + throw { + errCode: ERROR.CAPTCHA_REQUIRED + } + } await verifyCaptcha.call(this, { captcha, scene: CAPTCHA_SCENE.LOGIN_BY_PWD diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-mobile-by-sms.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-mobile-by-sms.js index 2275b05..12c2a67 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-mobile-by-sms.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-mobile-by-sms.js @@ -14,6 +14,9 @@ const { preBind, postBind } = require('../../lib/utils/relate') +const { + ERROR +} = require('../../common/error') /** * 通过短信验证码绑定手机号 @@ -47,6 +50,11 @@ module.exports = async function (params = {}) { type: LOG_TYPE.BIND_MOBILE }) if (needCaptcha) { + if (!captcha) { + throw { + errCode: ERROR.CAPTCHA_REQUIRED + } + } await verifyCaptcha.call(this, { captcha, scene: CAPTCHA_SCENE.BIND_MOBILE_BY_SMS -- GitLab