diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js index 3dba8b21fdb7583b9ae6dc7918ed769692ffa209..e49306ed34dc90463f0276b67f6381981bada428 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js @@ -33,8 +33,9 @@ const ERROR = { BIND_CONFLICT: 'uni-id-bind-conflict', UNBIND_FAIL: 'uni-id-unbind-failed', UNBIND_NOT_SUPPORTED: 'uni-id-unbind-not-supported', - UNBIND_UNIQUE_LOGIN: 'uni-id-unbind-unique-login' - + UNBIND_UNIQUE_LOGIN: 'uni-id-unbind-unique-login', + UNBIND_PASSWORD_NOT_EXISTS: 'uni-id-unbind-password-not-exists', + UNBIND_MOBILE_NOT_EXISTS: 'uni-id-unbind-mobile-not-exists' } function isUniIdError (errCode) { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js index 343158599daf7c63294b5d5473f0b9cf826f0045..3c04035718bf6b4a12695fe2c22ae268e1798c8d 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js @@ -39,7 +39,8 @@ const sentence = { 'uni-id-admin-exist-in-other-apps': 'Administrator is registered in other consoles', 'uni-id-unbind-failed': 'Please bind first and then unbind', 'uni-id-unbind-not-supported': 'Unbinding is not supported', - 'uni-id-unbind-unique-login': 'This is the only way to login at the moment, please bind your phone number and then try to unbind' + 'uni-id-unbind-mobile-not-exists': 'This is the only way to login at the moment, please bind your phone number and then try to unbind', + 'uni-id-unbind-password-not-exists': 'Please set a password first' } module.exports = { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js index d39231111d74744c70ce6abbb22ca5840bf6467e..9653033f988e5a8b1e0adde28101c76a15e6b6c1 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js @@ -39,7 +39,8 @@ const sentence = { 'uni-id-admin-exist-in-other-apps': '超级管理员已在其他控制台注册', 'uni-id-unbind-failed': '请先绑定后再解绑', 'uni-id-unbind-not-supported': '不支持解绑', - 'uni-id-unbind-unique-login': '这是当前唯一登录方式,请绑定手机号后再尝试解绑' + 'uni-id-unbind-mobile-not-exists': '这是当前唯一登录方式,请绑定手机号后再尝试解绑', + 'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑' } module.exports = { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js index 1563271c1ea006c12178c660d9f797784986e87c..360519a9ca6cdb327a0ed70cbb1e6341a4a6e81e 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js @@ -120,9 +120,19 @@ async function preUnBind ({ } } - if (!hasOtherAccountBind && !user.mobile) { - throw { - errCode: ERROR.UNBIND_UNIQUE_LOGIN + // 如果没有其他第三方登录方式 + if (!hasOtherAccountBind) { + // 存在用户名或者邮箱但是没有设置过没密码就提示设置密码 + if ((user.username || user.email) && !user.password) { + throw { + errCode: ERROR.UNBIND_PASSWORD_NOT_EXISTS + } + } + // 账号任何登录方式都没有就优先绑定手机号 + if (!user.mobile) { + throw { + errCode: ERROR.UNBIND_MOBILE_NOT_EXISTS + } } } }