Ejemplo n.º 1
0
 public function actionPassword_change()
 {
     $model = new \app\models\Form\PasswordNew();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->action(\Yii::$app->user->identity)) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         return $this->render(['model' => $model]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Активация восстановления пароля
  *
  * @param string $code
  *
  * @return Response
  * @throws Exception
  */
 public function actionPassword_recover_activate($code)
 {
     if (\yii\helpers\ArrayHelper::getValue(Yii::$app->params, 'isTransfere', false) == true) {
         throw new Exception(Yii::$app->params['isTransfere_string']);
     }
     $row = PasswordRecoverDispatcher::query(['code' => $code])->one();
     if ($row === false) {
         throw new Exception('Не верный код активации');
     }
     $user = User::find($row['parent_id']);
     if (is_null($user)) {
         throw new Exception('Пользователь не найден');
     }
     $model = new \app\models\Form\PasswordNew();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->action($user)) {
         PasswordRecoverDispatcher::delete($row['parent_id']);
         Yii::$app->user->login($user);
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->goHome();
     } else {
         return $this->render(['model' => $model]);
     }
 }