From 17065fab4177b4b56e844651cb774dcc3bb6b563 Mon Sep 17 00:00:00 2001 From: chaosBreaking Date: Sun, 29 Sep 2019 17:32:23 +0800 Subject: [PATCH] fix: api sms --- src/modules/msgCode/msgCode.controller.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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([