|
|
@@ -95,4 +95,31 @@ class UserController extends BaseController
|
|
|
util::success(['mobile' => $mobile]);
|
|
|
}
|
|
|
|
|
|
+ //密码修改
|
|
|
+ public function actionPassword()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $old = isset($post['old']) ? $post['old'] : '';
|
|
|
+ $new = isset($post['new']) ? $post['new'] : '';
|
|
|
+ $confirm = isset($post['confirm']) ? $post['confirm'] : '';
|
|
|
+ if (empty($new)) {
|
|
|
+ util::fail('请输入新密码');
|
|
|
+ }
|
|
|
+ if ($new != $confirm) {
|
|
|
+ util::fail('二次密码不一致');
|
|
|
+ }
|
|
|
+ $user = $this->user;
|
|
|
+ $userId = $this->userId;
|
|
|
+ if (!empty($user['password'])) {
|
|
|
+ if (empty($old)) {
|
|
|
+ util::fail('请填写旧密码');
|
|
|
+ }
|
|
|
+ if (password_verify($old , $user['password']) == false) {
|
|
|
+ util::fail('旧密码错误');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UserService::updateById($userId, ['password' => password_hash($new, PASSWORD_BCRYPT)]);
|
|
|
+ util::ok('修改成功');
|
|
|
+ }
|
|
|
+
|
|
|
}
|