忘记密码

admin1年前Laravel480

public
function forget()
{
   $phone = request()->input('phone');
   $code = request()->input('code');
   $pass = request()->input('pass', 123456);
   $repass = request()->input('repass', 123456);

   if (!$phone) {
       return $this->error('请输入手机号');
   }

   $num = Db::table('member')->where(array('phone' => $phone))->first();

   if (!$num) {
       return $this->error('手机号不存在');
   }

   if (!$pass) {
       return $this->error('请输入密码');
   }

   if (!$repass) {
       return $this->error('请输入确认密码');
   }

   if ($pass != $repass) {
       return $this->error('两个密码不一致');
   }

   $nums = (array)Db::table('code')->where(array('phone' => $phone, 'status' => 0))->orderByDesc('time')->first();
   if ($nums) {
       if ($nums['code'] != $code) {
           return $this->error('验证码不正确');
       } else {
           Db::table('code')->where(array('id' => $nums['id']))->update(['status' => 1]);
       }
   } else {
       return $this->error('请先发送验证码');
   }


   $info = Db::table('member')->where(array('phone' => $phone))->update(['pass' => MD5($pass . $this->MD5)]);

   if ($info !== false) {
       return $this->success('ok');
   } else {
       return $this->error('error');
   }


}

相关文章

公众号登录

public function wxlogin(){       $code = request()->input('code'); &n...

按照距离远近排序

   $distance = "ACOS(SIN(( $lat * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((...

过滤违禁词

/** * 内容验证 */public function check($content){    $count = 0; //违规词的个数    $list =...

微信退款v2

/** * 微信 退款 操作 */ public function refund($out_trade_no, $total_fee) { $parma =...

查找下级所有数据

public function bottom($mid = 3){    $members = DB::select('select id,parent_id,`level...

手机号替换

 $vv = substr_replace($vv, '****', 3, 4) ....