Ejemplo n.º 1
0
 /**
  * Confirm new e-mail address.
  *
  * @param string $key Confirmation token
  */
 public function actionEmail($key)
 {
     $model = new Email(['token' => $key]);
     if ($model->isValidToken() === false) {
         Yii::$app->session->setFlash('danger', Yii::t('users', 'FRONTEND_FLASH_FAIL_NEW_EMAIL_CONFIRMATION_WITH_INVALID_KEY'));
     } else {
         if ($model->confirm()) {
             Yii::$app->session->setFlash('success', Yii::t('users', 'FRONTEND_FLASH_SUCCESS_NEW_EMAIL_CONFIRMATION'));
         } else {
             Yii::$app->session->setFlash('danger', Yii::t('users', 'FRONTEND_FLASH_FAIL_NEW_EMAIL_CONFIRMATION'));
         }
     }
     return $this->goHome();
 }
Ejemplo n.º 2
0
 /**
  * Request email change page.
  */
 public function actionEmail()
 {
     $model = new Email();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->save(false)) {
                 Yii::$app->session->setFlash('success', Module::t('users', 'FRONTEND_FLASH_SUCCES_EMAIL_CHANGE'));
                 return $this->goHome();
             } else {
                 Yii::$app->session->setFlash('danger', Module::t('users', 'FRONTEND_FLASH_FAIL_EMAIL_CHANGE'));
                 return $this->refresh();
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     return $this->render('email', ['model' => $model]);
 }