|
@@ -302,4 +302,35 @@ class User extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改密码
|
|
|
+ *
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $newpassword 新密码
|
|
|
+ * @param string $oldpassword 旧密码
|
|
|
+ */
|
|
|
+ public function changepwd(){
|
|
|
+ $newpassword = input('newpassword');
|
|
|
+ $oldpassword = input('oldpassword','');
|
|
|
+
|
|
|
+ if (!$newpassword) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ if($this->auth->password && empty($oldpassword)){
|
|
|
+ $this->error('原密码必填');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($this->auth->password)){
|
|
|
+ $ret = $this->auth->changepwd($newpassword, '', true);
|
|
|
+ }else{
|
|
|
+ $ret = $this->auth->changepwd($newpassword,$oldpassword,false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($ret) {
|
|
|
+ $this->success(__('Reset password successful'));
|
|
|
+ } else {
|
|
|
+ $this->error($this->auth->getError());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|