ソースを参照

admin/checkpwd

wugg 3 年 前
コミット
52260f7ed5
2 ファイル変更24 行追加0 行削除
  1. 23 0
      application/Admin/controller/Account.php
  2. 1 0
      application/route.php

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

@@ -351,4 +351,27 @@ class Account extends Base
             return error_show(1003, $e->getMessage());
         }
     }
+    public  function  checkPwd(){
+       $id=  isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
+       if($id===''){
+           return error_show(1004, "参数id 不能为空");
+       }
+        $info = Db::name("account")->where(["is_del" => 0, "id" => $id])->find();
+        if (empty($info)) {
+            return error_show(1004, "未找到数据");
+        }
+       $pasword = isset($this->post['password']) && $this->post['password'] !== "" ? trim($this->post['password']) : "";
+        if($pasword===''){
+            return error_show(1004, "参数password 不能为空");
+        }
+        if ($info['pwd']==$pasword) {
+            return error_show(1004, "新密码不能与原密码相同");
+        }
+            $salt = makeSalt();
+            $info['password'] = sha1($pasword . $salt);
+            $info['pwd'] = $pasword;
+            $info['updatetime'] = date("Y-m-d H:i:s");
+        $acc= Db::name("account")->update($info);
+        return $acc ?app_show(0,"账户密码修改成功"): error_show(1005, "账户密码修改失败");
+    }
 }

+ 1 - 0
application/route.php

@@ -36,6 +36,7 @@ Route::rule('admin/accountinfo','Admin/Account/Read');
 Route::rule('admin/accountlist','Admin/Account/List');
 Route::rule('admin/accountadd','Admin/Account/Create');
 Route::rule('admin/accountsave','Admin/Account/Save');
+Route::rule('admin/checkpwd','Admin/Account/checkPwd');
 
 Route::rule('admin/orderlist','Admin/Order/list');
 Route::rule('admin/orderdelivery','Admin/Order/OrderDelivery');