public function actionValidateChangeEmailForm()
 {
     $cEmailFrm = new ChangeEmailForm();
     if (Yii::$app->request->isAjax && $cEmailFrm->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($cEmailFrm);
     }
 }
Пример #2
0
 public function actionChangeEmail()
 {
     $cEmailFrm = new ChangeEmailForm();
     $status = 'ERROR';
     $message = Common::M_CHANGE_EMAIL_FAILED;
     if ($cEmailFrm->load(Yii::$app->request->post()) && $cEmailFrm->validate()) {
         $user = User::findIdentity(Yii::$app->user->id);
         if ($user) {
             $user->setEmail($cEmailFrm->email);
             $status = 'OK';
             $message = Common::M_EMAIL_CHANGED;
         }
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     $responce = ['status' => $status, 'message' => $message];
     return $responce;
 }