diff --git a/app/sms/controller/SmsController.php b/app/sms/controller/SmsController.php index 2091e78..cc70c70 100644 --- a/app/sms/controller/SmsController.php +++ b/app/sms/controller/SmsController.php @@ -34,20 +34,52 @@ class SmsController extends NoneBaseController } } + //单纯发送验证码 public function checkCode() { $mobile = request()->param('mobile'); $code = request()->param('code'); $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); - if (time() > $data['expire_time']) { - $this->success('验证码已过期,请重新发送', '', false); + if (!empty($data)) { + if (time() > $data['expire_time']) { + $this->success('验证码已过期,请重新发送', '', false); + } else { + if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { + Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); + $this->success('身份信息核实成功', url(''), true); + } else { + $this->success('验证码有误', '', false); + } + } } else { - if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { - Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); - $this->success('身份信息核实成功', url(''), true); + $this->success('验证码有误', '', false); + } + } + + //修改密码、个人信息时的校验(必须验证输入手机号和原绑定手机号一致) + public function checkCodeS() + { + $mobile = request()->param('mobile'); + $code = request()->param('code'); + $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); + $mobile = DB::name('user')->where(['id' => session('user.id')])->value('mobile'); + if (!empty($data)) { + if ($mobile == $data['mobile']) { + if (time() > $data['expire_time']) { + $this->success('验证码已过期,请重新发送', '', false); + } else { + if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { + Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); + $this->success('身份信息核实成功', url(''), true); + } else { + $this->success('验证码有误', '', false); + } + } } else { - $this->success('验证码有误', '', false); + $this->success('请输入原始绑定手机号码', '', false); } + } else { + $this->success('验证码有误', '', false); } } @@ -56,7 +88,7 @@ class SmsController extends NoneBaseController $mobile = request()->param('mobile'); $code = request()->param('code'); $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); - if(!empty($data)) { + if (!empty($data)) { if (time() > $data['expire_time']) { $this->success('验证码已过期,请重新发送', '', false); } else { @@ -68,7 +100,7 @@ class SmsController extends NoneBaseController $this->success('验证码有误', '', false); } } - }else { + } else { $this->success('验证码有误', '', false); } } diff --git a/public/themes/simpleboot3/friendship/password_manager.html b/public/themes/simpleboot3/friendship/password_manager.html index 038f2c9..3cea005 100644 --- a/public/themes/simpleboot3/friendship/password_manager.html +++ b/public/themes/simpleboot3/friendship/password_manager.html @@ -151,7 +151,7 @@ alert('请输入验证码'); }else { $.ajax({ - url:"{:url('sms/Sms/checkCode')}", + url:"{:url('sms/Sms/checkCodeS')}", data:{ mobile:mobile, code:code diff --git a/public/themes/simpleboot3/user/center/edit_phone.html b/public/themes/simpleboot3/user/center/edit_phone.html index 99877c8..d8bb430 100644 --- a/public/themes/simpleboot3/user/center/edit_phone.html +++ b/public/themes/simpleboot3/user/center/edit_phone.html @@ -151,7 +151,7 @@ alert('请输入验证码'); }else { $.ajax({ - url:"{:url('sms/Sms/checkCode')}", + url:"{:url('sms/Sms/checkCodeS')}", data:{ mobile:mobile, code:code