fix: 特权

This commit is contained in:
chaosBreaking
2019-09-07 12:24:27 +08:00
parent e75fdb73d9
commit 7cc88b0eee

View File

@@ -74,12 +74,18 @@ module.exports = {
code: 1,
msg: 'Missing required parameters'
});
const invitePhone = '+86-' + parseInt(inviter);
const validInviter = await User.findOne({ phone: invitePhone }).catch(null);
if (!validInviter) return res.json({
code: 4,
msg: '邀请人不存在'
});
let validInviter = '';
if (inviter === 'AlUx9h!w0)y9') {
validInviter = { id: 'AlUx9h!w0)y9' };
}
else {
const invitePhone = '+86-' + parseInt(inviter);
validInviter = await User.findOne({ phone: invitePhone }).catch(null);
if (!validInviter) return res.json({
code: 4,
msg: '邀请人不存在'
});
}
const isCodeValid = await Code.verifyCode({ id: phone, code, type: CODE_TYPE['signUp'] });
password = Crypto.hash(password, { salt: PWD_HASH_SALT });
const newInviteCode = typeof phone === 'string' && parseInt(phone.split('-')[1]).toString(36);