fix: api sms

This commit is contained in:
chaosBreaking
2019-09-29 17:32:23 +08:00
parent 9349d6ed86
commit 17065fab41

View File

@@ -22,6 +22,14 @@ module.exports = {
CODE_TYPE, CODE_TYPE,
async sendMsgCode (phone, type) { async sendMsgCode (phone, type) {
const validCodeType = CODE_TYPE[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) { if (phone && type && validCodeType) {
const code = Crypto.randomNumber({length: 6}); const code = Crypto.randomNumber({length: 6});
const [ sms, save ] = await Promise.all([ const [ sms, save ] = await Promise.all([