feat: 邀请人验证

This commit is contained in:
chaosBreaking
2019-09-01 22:53:19 +08:00
parent d4987df574
commit 3dc188faa1

View File

@@ -72,6 +72,11 @@ module.exports = {
code: 1, code: 1,
msg: 'Missing required parameters' msg: 'Missing required parameters'
}); });
const validInviter = await User.findById(inviter).catch(err => null);
if (!validInviter) return res.json({
code: 4,
msg: '邀请人不存在'
});
const isCodeValid = await Code.verifyCode({ id: phone, code, type: CODE_TYPE['signUp'] }); const isCodeValid = await Code.verifyCode({ id: phone, code, type: CODE_TYPE['signUp'] });
password = Crypto.hash(password, { salt: PWD_HASH_SALT }); password = Crypto.hash(password, { salt: PWD_HASH_SALT });
if (isCodeValid) { if (isCodeValid) {