Ejemplo n.º 1
0
 public function testUserEmailChange()
 {
     $newEmail = '*****@*****.**';
     $model = $this->user;
     $profileForm = new ProfileForm();
     $this->assertTrue($model !== NULL);
     $profileForm->load($model->id, true);
     $profileForm->email = $newEmail;
     // Verify that the profile form saves
     $this->assertTrue($profileForm->save());
     // Verify that the base user model didn't change
     $model = $this->getUserModel();
     $this->assertTrue($model->email == '*****@*****.**');
     $newEmailModel = UserMetadata::model()->findByAttributes(array('user_id' => $this->user->id, 'key' => 'newEmailAddress'));
     // Verify that the new email is stored in the database
     $this->assertTrue($newEmailModel !== NULL);
     $this->assertTrue($newEmailModel->value == $newEmail);
     $key = UserMetadata::model()->findByAttributes(array('user_id' => $this->user->id, 'key' => 'newEmailAddressChangeKey'));
     $this->assertTrue($key !== NULL);
     $emailChangeForm = new EmailChangeForm();
     $emailChangeForm->setUser($this->getUserModel());
     $emailChangeForm->verificationKey = $key->value;
     $emailChangeForm->password = '******';
     // Verify that the verification key works
     $this->assertTrue($emailChangeForm->validateVerificationKey());
     // Veirfy that the email address changes
     $this->assertTrue($emailChangeForm->validate());
     $this->assertTrue($emailChangeForm->save());
     // Verify that the email has changed for the model now
     $model = Users::model()->findByAttributes(array('email' => '*****@*****.**'));
     $this->assertTrue($model->email == $newEmail);
 }
Ejemplo n.º 2
0
 /**
  * Send a new verification email to the user
  */
 public function actionResend()
 {
     $model = new ProfileForm();
     $model->load(Yii::app()->user->id);
     // If we don't have one on file, then someone the user got to a page they shouldn't have gotten to
     // Seamlessly redirect them back
     if ($model->getNewEmail() == NULL) {
         $this->redirect(Yii::app()->user->returnUrl);
     }
     if ($model->sendVerificationEmail()) {
         Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'A new verification email has been resent to {{user}}. Please check your email address.', array('{{user}}' => $model->getNewEmail())));
     } else {
         Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There was an error resending the verification email. Please try again later.'));
     }
     $this->redirect($this->createUrl('profile/edit'));
 }