public function change($runValidation = true)
{
if ($runValidation && !$this->validate()) {
return false;
}
$user = Yii::$app->user->identity;
$user->password = $this->password;
return $user->save(false);
}
/** * 修改密码 * * @return array */ public function actionPassword() { $model = new ChangePasswordForm(); if ($model->load(Yii::$app->request->post(), '') && $model->change()) { return ['status' => 'success', 'data' => []]; } else { return ['status' => 'fail', 'data' => ['errors' => $model->getFirstErrors()]]; } }