|
|
@@ -66,13 +66,15 @@ class UserController {
|
|
|
ctx.body = Response.failed('验证码错误');
|
|
|
}else{
|
|
|
const hashPassword = bcrypt.hashSync(data.password, 10);
|
|
|
- const user = await userModel.create(data.name, hashPassword, data.phone, data.email);
|
|
|
+ const result = await userModel.create(data.name, hashPassword, data.phone, data.email);
|
|
|
ctx.session.verification_phone = undefined;
|
|
|
ctx.session.verification_code = undefined;
|
|
|
- if (user) {
|
|
|
- ctx.body = Response.success({name: user.name});
|
|
|
- } else {
|
|
|
+ if (result.code === 0) {
|
|
|
+ ctx.body = Response.success({name: result.data.name});
|
|
|
+ } else if(result.code === -2){
|
|
|
ctx.body = Response.failed('此手机号已注册');
|
|
|
+ } else if(result.code === -1){
|
|
|
+ ctx.body = Response.failed('此用户名已使用');
|
|
|
}
|
|
|
}
|
|
|
}
|