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