email注册时增加判断

This commit is contained in:
zhl 2023-05-08 17:34:06 +08:00
parent 58e7c713ed
commit 88a17b515b

View File

@ -117,6 +117,12 @@ class MailController extends BaseController {
throw new ZError(10, 'params mismatch')
}
type = parseInt(type)
if (type === CodeType.REGIST) {
let account = await Account.findByEmail(email)
if (account) {
throw new ZError(11, 'account exists')
}
}
let record = await CodeRecord.findByEmail(email, type)
if (!record) {
record = new CodeRecord({ email, type, code: DEFAULT_CODE })
@ -158,6 +164,6 @@ class MailController extends BaseController {
throw new ZError(10, 'params mismatch')
}
let account = await Account.findByEmail(email)
return { exists: !account }
return { exists: !!account }
}
}