修改密码

admin2年前Laravel899


/**
* 修改密码
*/
public
function setpass()
{

   $type = request()->input('type');// 1 密码 2支付密码
   $phone = request()->input('phone');
   $code = request()->input('code');
   $pass = request()->input('pass', 123456);
   $repass = request()->input('repass', 123456);

   if (!$type) {
       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('请先发送验证码');
   }


   if ($type == '1') {
       $info = Db::table('member')->where(array('id' => $this->user_id))->update(['pass' => MD5($pass . $this->MD5)]);
   } else {
       $info = Db::table('member')->where(array('id' => $this->user_id))->update(['pay_pass' => MD5($pass . $this->MD5)]);
   }

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

相关文章

过滤违禁词

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

批量处理数据

   public function index44()    {        $domain = request(...

按照距离远近排序

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

下载文件

public function img_url() { $id = request()->param('id', 1122); $info = Db::name('...

设置项目编号

$max = Db::table('member')->max('id') ?? 0; if ($max < 100000) { $cd = $this->create...

接口返回处理

public function __construct()    {        $action = request()->rout...