xieruidong há 2 anos atrás
pai
commit
3084d45173

+ 19 - 1
application/api/controller/User.php

@@ -362,7 +362,25 @@ class User extends Api
 
         $this->success('',$info);
     }
-
+    /**
+     * 密码方式修改密码
+     * @ApiParams (name=old_pwd,description=旧密码)
+     * @ApiParams (name=new_pwd,description=旧密码)
+     * @ApiParams (name=new_pwd_confirm,description=旧密码确认密码)
+     */
+    public function changepwd(){
+        $user=$this->auth->getUser();
+        $data=$this->_validate([
+            'old_pwd|旧密码'=>['require','min:6'],
+            'new_pwd|新密码'=>['require','min:6'],
+            'new_pwd_confirm|确认新密码'=>['require','min:6','confirm:new_pwd'],
+        ]);
+        if ($user->password != $this->auth->getEncryptPassword($data['old_pwd'], $user->salt)) {
+            $this->error('密码错误');
+        }
+        $this->auth->changepwd($data['new_pwd']);
+        $this->success();
+    }
     /**
      * 重置密码
      *

+ 11 - 6
application/api/controller/Validate.php

@@ -162,14 +162,19 @@ class Validate extends Api
         $this->success();
     }
     /**
-     * 手机号规律
-     * @ApiParams (name=mobile)
+     * 检测密码是否正确
+     * @ApiParams (name=password,description=原密码)
+     * @ApiReturnParams (name=right,description=是否正确)
      */
     public function check_mobile_rule_validate(){
-        $mobile=input('mobile');
-        if(!$mobile){
-            $this->error();
+        $password=input('password');
+        $info=[
+            'right'=>true,
+        ];
+        $user=$this->auth->getUser();
+        if($user && $password){
+            $info['right']=$user->password===$this->auth->getEncryptPassword($password,$user->salt);
         }
-        $this->success('',MobileComputer::setMobile($mobile)->filter());
+        $this->success('',$info);
     }
 }

+ 2 - 0
application/common/model/User.php

@@ -26,6 +26,8 @@ use think\model\relation\HasMany;
  * @property string mobile
  * @property string bio
  * @property string nickname
+ * @property string password
+ * @property string salt
  * @property UserInfo userinfo
  * @property boolean wx_authed 是否已微信授权
  * @property boolean is_vip

Diff do ficheiro suprimidas por serem muito extensas
+ 309 - 154
public/api.html


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff