diff --git a/src/controllers/mail.controller.ts b/src/controllers/mail.controller.ts index 5df985a..78a2e46 100644 --- a/src/controllers/mail.controller.ts +++ b/src/controllers/mail.controller.ts @@ -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 } } }