diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/validator.test.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/validator.test.js index 3376b4079eba3d544721157ba54ba22c6b814780..bad62e79f73911327c3528c1ee8b3ad4119cf327 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/validator.test.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/validator.test.js @@ -191,6 +191,100 @@ const testCaseList = [{ expected: { errCode: ERROR.PARAM_REQUIRED } +}, { + value: { + mobile: '18811112222' + }, + schema: { + mobile: 'mobile' + } +}, { + value: { + mobile: '18811112222' + }, + schema: { + mobile: { + required: false, + type: 'mobile' + } + } +}, { + value: { + mobile: '' + }, + schema: { + mobile: 'mobile' + }, + expected: { + errCode: ERROR.PARAM_REQUIRED + } +}, { + value: { + mobile: '' + }, + schema: { + mobile: { + required: false, + type: 'mobile' + } + } +}, { + value: { + mobile: '123456' + }, + schema: { + mobile: 'mobile' + }, + expected: { + errCode: ERROR.INVALID_MOBILE + } +}, { + value: { + email: 'test@dcloud.io' + }, + schema: { + email: 'email' + } +}, { + value: { + email: 'test@dcloud.io' + }, + schema: { + email: { + required: false, + type: 'email' + } + } +}, { + value: { + email: '' + }, + schema: { + email: 'email' + }, + expected: { + errCode: ERROR.PARAM_REQUIRED + } +}, { + value: { + email: '' + }, + schema: { + email: { + required: false, + type: 'email' + } + } +}, { + value: { + email: 'test' + }, + schema: { + email: 'email' + }, + expected: { + errCode: ERROR.INVALID_EMAIL + } }] function execTestCase ({ @@ -209,7 +303,7 @@ function execTestCase ({ validator.mixin(type, handler) } let validateResult, - validateError + validateError try { validateResult = validator.validate(value, schema) } catch (err) { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/config.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/config.js index fdc71605c3a85cc8570d8ef547635c27bab917d2..48d568894d732ad23fa3ef2b9e2757d4fcebd9c9 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/config.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/config.js @@ -22,7 +22,7 @@ class ConfigUtils { context } = {}) { this.context = context - this.clientInfo = context.getClientInfo() + this.clientInfo = context.getUniversalClientInfo() const { appId, uniPlatform diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/verify-request-sign.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/verify-request-sign.js index 64286f72c757d6d00c757c63f9cfddf346ca136e..84420e3afbbf6861719b48cbd0941519b33c1b6e 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/verify-request-sign.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/verify-request-sign.js @@ -7,7 +7,7 @@ const needSignFunctions = new Set([ module.exports = function () { const methodName = this.getMethodName() - const { source } = this.getClientInfo() + const { source } = this.getUniversalClientInfo() // 非 HTTP 方式请求不需要鉴权 if (source !== 'http') return // 指定接口需要鉴权