Browse Source

add register params check

Starink 6 years ago
parent
commit
a07a99baab
1 changed files with 2 additions and 0 deletions
  1. 2 0
      server/controller/user.js

+ 2 - 0
server/controller/user.js

@@ -69,6 +69,8 @@ class UserController {
           ctx.body = Response.failed('验证码错误');
         }else if(!myReg.test(data.email)){
           ctx.body = Response.failed('邮箱格式有误');
+        }else if(data.name.length<1 || data.name.length>10 || data.password.length<6 || data.password.length>20 || data.phone!==11){
+          ctx.body = Response.failed('参数非法');
         }else{
           const hashPassword = bcrypt.hashSync(data.password, 10);
           const result = await userModel.create(data.name, hashPassword, data.phone, data.email);