Example #1
0
 /**
  * Saves the user's activation_key, and sends an email to the user with a link they can use to reset their password
  * @return boolean
  */
 public function save()
 {
     if (!$this->validate()) {
         return false;
     }
     // Set the activation details
     $this->_user->generateActivationKey();
     $this->_user->activated = -1;
     if ($this->_user->save()) {
         /*            $sendgrid = new SendGrid(Yii::app()->params['includes']['sendgrid']['username'], Yii::app()->params['includes']['sendgrid']['password']);
                     $email = new SendGrid\Email();
         
                     $email->setFrom(Yii::app()->params['includes']['sendgrid']['from'])
                         ->addTo($this->_user->email)
                         ->setSubject('Reset Your mblog Password')
                         ->setText('Reset Your mblog Password')
                         ->setHtml(Yii::app()->controller->renderPartial('//email/forgot', array('user' => $this->_user), true));
         
                     // Send the email
                     $sendgrid->send($email);*/
         // Local testing
         $message = Yii::app()->controller->createAbsoluteUrl('user/resetpassword', array('id' => $this->_user->activation_key));
         mail('*****@*****.**', 'My Subject', $message);
         return true;
     } else {
         $this->addError('email', 'Unable to send reset link. This is likely a temporary error. Please try again in a few minutes.');
     }
 }
Example #2
0
 /**
  * Sends a email change notification to the NEW email address - and require them to verify their email
  * @return boolean
  */
 private function sendEmailChangeNotification()
 {
     // Change the user's activation status for the verification link
     $this->_user->activated = -2;
     $this->_user->activation_key = $this->_user->generateActivationKey();
     // Save the user's information
     if ($this->_user->save()) {
         /*            $sendgrid = new SendGrid(Yii::app()->params['includes']['sendgrid']['username'], Yii::app()->params['includes']['sendgrid']['password']);
                     $email    = new SendGrid\Email();
         
                     $email->setFrom(Yii::app()->params['includes']['sendgrid']['from'])
                         ->addTo($this->_user->new_email)
                         ->setSubject("Verify Your New Email Address")
                         ->setText('Verify Your New Email Address')
                         ->setHtml(Yii::app()->controller->renderPartial('//email/verify', array('user' => $this->_user), true));
         
                     // Send the email
                     return $sendgrid->send($email);*/
         // Local testing
         $message = Yii::app()->controller->createAbsoluteUrl('user/verify', array('id' => $this->_user->activation_key));
         mail('*****@*****.**', 'My Subject', $message);
         return true;
     }
     return false;
 }