开放注册

This commit is contained in:
chaosBreaking
2019-10-04 17:21:19 +08:00
parent 6b7d95f548
commit 2e35fe1aa5

View File

@@ -72,26 +72,22 @@ module.exports = {
signUpReqInviter: inject(function(SysConfig) { signUpReqInviter: inject(function(SysConfig) {
const { JWT_SECRET, PWD_HASH_SALT } = SysConfig; const { JWT_SECRET, PWD_HASH_SALT } = SysConfig;
return async (req, res) => { return async (req, res) => {
// return res.json({
// code: 404,
// msg: '暂停注册'
// });
let { phone, code, inviter, password } = req.body; let { phone, code, inviter, password } = req.body;
if (!phone || !code || !password || !inviter) return res.json({ if (!phone || !code || !password || !inviter) return res.json({
code: 1, code: 1,
msg: 'Missing required parameters' msg: '非法请求'
}); });
phone = String.prototype.trim.call(phone); phone = String.prototype.trim.call(phone);
const isValidPhone = phone.startsWith('+86-') ? phoneRegCN.test(phone) : true; //国际手机暂不检测 const isValidPhone = phone.startsWith('+86-') ? phoneRegCN.test(phone) : true; //国际手机暂不检测
if (!isValidPhone) return res.json({ if (!isValidPhone) return res.json({
code: 5, code: 5,
msg: 'Invalid phone', msg: '无效手机号',
}); });
const isValidCode = await Code.verifyCode({ id: phone, code, type: CODE_TYPE['signUp'] }); const isValidCode = await Code.verifyCode({ id: phone, code, type: CODE_TYPE['signUp'] });
if (!isValidCode) { if (!isValidCode) {
return res.json({ return res.json({
code: 2, code: 2,
msg: 'Invalid code', msg: '验证码错误',
}); });
} }
let validInviter = ''; let validInviter = '';
@@ -201,10 +197,6 @@ module.exports = {
}; };
}), }),
sendMsgCode: async (req, res) => { sendMsgCode: async (req, res) => {
return res.json({
code: 404,
msg: '暂停注册'
});
// 可作为通用的发送验证码接口 // 可作为通用的发送验证码接口
let { phone, type } = req.body; let { phone, type } = req.body;
// 注意此处的type是字面值不是数值应该是例如'signIn'等 // 注意此处的type是字面值不是数值应该是例如'signIn'等
@@ -212,12 +204,12 @@ module.exports = {
if (exec && exec.code === 0) { if (exec && exec.code === 0) {
res.json({ res.json({
code: 0, code: 0,
msg: 'Code sended' msg: '验证码已发送'
}); });
} else { } else {
res.json({ res.json({
code: exec.code ? exec.code : 1, code: exec.code ? exec.code : 1,
error: exec.error ? exec.error : 'failed' error: exec.error ? exec.error : '发送失败'
}); });
} }
}, },