提交 0e06b551 编写于 作者: C chenruilong

chore: 解绑第三方账号时验证邮箱与用户名

上级 62c2c41f
...@@ -33,8 +33,9 @@ const ERROR = { ...@@ -33,8 +33,9 @@ const ERROR = {
BIND_CONFLICT: 'uni-id-bind-conflict', BIND_CONFLICT: 'uni-id-bind-conflict',
UNBIND_FAIL: 'uni-id-unbind-failed', UNBIND_FAIL: 'uni-id-unbind-failed',
UNBIND_NOT_SUPPORTED: 'uni-id-unbind-not-supported', 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) { function isUniIdError (errCode) {
......
...@@ -39,7 +39,8 @@ const sentence = { ...@@ -39,7 +39,8 @@ const sentence = {
'uni-id-admin-exist-in-other-apps': 'Administrator is registered in other consoles', '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-failed': 'Please bind first and then unbind',
'uni-id-unbind-not-supported': 'Unbinding is not supported', '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 = { module.exports = {
......
...@@ -39,7 +39,8 @@ const sentence = { ...@@ -39,7 +39,8 @@ const sentence = {
'uni-id-admin-exist-in-other-apps': '超级管理员已在其他控制台注册', 'uni-id-admin-exist-in-other-apps': '超级管理员已在其他控制台注册',
'uni-id-unbind-failed': '请先绑定后再解绑', 'uni-id-unbind-failed': '请先绑定后再解绑',
'uni-id-unbind-not-supported': '不支持解绑', 'uni-id-unbind-not-supported': '不支持解绑',
'uni-id-unbind-unique-login': '这是当前唯一登录方式,请绑定手机号后再尝试解绑' 'uni-id-unbind-mobile-not-exists': '这是当前唯一登录方式,请绑定手机号后再尝试解绑',
'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑'
} }
module.exports = { module.exports = {
......
...@@ -120,9 +120,19 @@ async function preUnBind ({ ...@@ -120,9 +120,19 @@ async function preUnBind ({
} }
} }
if (!hasOtherAccountBind && !user.mobile) { // 如果没有其他第三方登录方式
if (!hasOtherAccountBind) {
// 存在用户名或者邮箱但是没有设置过没密码就提示设置密码
if ((user.username || user.email) && !user.password) {
throw { throw {
errCode: ERROR.UNBIND_UNIQUE_LOGIN errCode: ERROR.UNBIND_PASSWORD_NOT_EXISTS
}
}
// 账号任何登录方式都没有就优先绑定手机号
if (!user.mobile) {
throw {
errCode: ERROR.UNBIND_MOBILE_NOT_EXISTS
}
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册