public function actionValidateChangePasswordForm()
 {
     $cPasFrm = new ChangePasswordForm();
     if (Yii::$app->request->isAjax && $cPasFrm->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($cPasFrm);
     }
 }
Exemplo n.º 2
0
 public function actionChangePassword()
 {
     $cPasFrm = new ChangePasswordForm();
     $status = 'ERROR';
     $message = Common::M_CHANGE_PASSWORD_FAILED;
     if ($cPasFrm->load(Yii::$app->request->post()) && $cPasFrm->validate()) {
         $user = User::findIdentity(Yii::$app->user->id);
         if ($user) {
             $user->setPassword($cPasFrm->new_password);
             $status = 'OK';
             $message = Common::M_PASSWORD_CHANGED;
         }
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     $responce = ['status' => $status, 'message' => $message];
     return $responce;
 }