diff --git a/src/modules/msgCode/msgCode.controller.js b/src/modules/msgCode/msgCode.controller.js index 5306bf2..f1c21c4 100644 --- a/src/modules/msgCode/msgCode.controller.js +++ b/src/modules/msgCode/msgCode.controller.js @@ -22,6 +22,14 @@ module.exports = { CODE_TYPE, async sendMsgCode (phone, type) { const validCodeType = CODE_TYPE[type]; + const exist = await Code.exists({ + id: phone, + type: CODE_TYPE[type] + }); + if (exist) return { + code: 1, + error: '请勿多次请求' + }; if (phone && type && validCodeType) { const code = Crypto.randomNumber({length: 6}); const [ sms, save ] = await Promise.all([