panlumeng 3 years ago
parent
commit
4548b8469c

+ 3 - 0
application/Admin/controller/Account.php

@@ -367,6 +367,9 @@ class Account extends Base
         if ($info['pwd']==$pasword) {
             return error_show(1004, "新密码不能与原密码相同");
         }
+//        if (!checkPasswd($pasword)) {
+//            return error_show(1004, "密码格式不正确");
+//        }
             $salt = makeSalt();
             $info['password'] = sha1($pasword . $salt);
             $info['pwd'] = $pasword;

+ 43 - 0
application/Home/controller/Login.php

@@ -78,4 +78,47 @@ class Login
             return error_show(1004,"退出失败");
         }
     }
+
+    public function passwd(){
+        $post=request()->post();
+        $username = isset($post['username']) && $post['username'] !== "" ? $post['username'] : "";
+       // var_dump($post);
+        if($username==""){
+            return error_show(1004, "参数username不能为空");
+        }
+        $info = Db::name("account")->where(["is_del" => 0, "username" =>$username ])->find();
+        if (empty($info)) {
+            return error_show(1004, "未找到数据");
+        }
+        $pas = isset($post['pas']) && $post['pas'] !== "" ? trim($post['pas']) : "";
+      //  var_dump($pas);
+        if($pas==""){
+            return error_show(1002,"参数pas不能为空");
+        }
+//        var_dump(sha1($pas.$info['salt']));
+//        var_dump($info['password']);
+        if(sha1($pas.$info['salt'])!==$info['password']){
+            return error_show(1004, "原密码填写不正确");
+        }
+
+        $pasword = isset($post['pasword']) && $post['pasword'] !== "" ? trim($post['pasword']) : "";
+       // var_dump($pasword);
+        if($pasword===""){
+            return error_show(1004, "参数password 不能为空");
+        }
+        if ($pas==$pasword) {
+            return error_show(1004, "新密码不能与原密码相同");
+        }
+//        if (!checkPasswd($pasword)) {
+//            return error_show(1004, "密码格式不正确");
+//        }
+        $salt=makeSalt();
+        $info['salt']=$salt;
+        $info['password']=sha1($pasword . $salt);
+        $info['pwd']=$pasword;
+        $info['updatetime']=date("Y-m-d H:i:s");
+
+        $item = Db::name('account')->where(['username'=>$username,'is_del'=>0])->update($info);
+        return $item ?app_show(0,"账户密码修改成功"): error_show(1005, "账户密码修改失败");
+    }
 }

+ 2 - 0
application/Home/controller/User.php

@@ -23,4 +23,6 @@ class User extends Base
         .accountid"=>$this->userinfo['id'],"b.is_del"=>0])->select();
         return  app_show(0,"获取成功", $list);
     }
+
+
 }

+ 1 - 0
application/route.php

@@ -64,6 +64,7 @@ Route::rule('admin/expire','Admin/Expire/update');
 Route::rule("home/login","Home/Login/index");
 
 Route::rule("home/userinfo","Home/User/info");
+Route::rule('home/password','Home/Login/passwd');
 
 Route::rule("home/addrlist","Home/Addr/list");
 Route::rule("home/addrinfo","Home/Addr/Info");