Skip to content

Commit

Permalink
[HZ-264] fixed errors in email confirmation after email change, then …
Browse files Browse the repository at this point in the history
…reverted to using existing helper function
  • Loading branch information
nkissebe committed May 10, 2024
1 parent d2cbb06 commit 41ca54c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/components/com_members/helpers/utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static function genemailconfirm()
* @param object $xregistration
* @return bool
*/
public static function sendConfirmEmail($user, $xregistration)
public static function sendConfirmEmail($user, $xregistration, $new = true)
{
$baseURL = rtrim(Request::root(), '/');

Expand All @@ -216,6 +216,7 @@ public static function sendConfirmEmail($user, $xregistration)
$eview->xprofile = $user;
$eview->baseURL = $baseURL;
$eview->xregistration = $xregistration;
$eview->new = $new;

$msg = new \Hubzero\Mail\Message();
$msg->setSubject($subject)
Expand Down
21 changes: 18 additions & 3 deletions core/components/com_members/site/controllers/profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,19 @@ public function saveTask()
// Send a new confirmation code AFTER we've successfully saved the changes to the e-mail address
if ($email != $oldemail)
{
$this->_sendConfirmationCode($member->get('username'), $email, $confirm);
$result = \Components\Members\Helpers\Utility::sendConfirmEmail($user, null, false);

if ($result)
{
Notify::success('A confirmation email has been sent to "'. htmlentities($email, ENT_COMPAT, 'UTF-8') .'". You must click the link in that email to re-activate your account.');
}
else
{
Notify::error('An error occurred emailing "'. htmlentities($email, ENT_COMPAT, 'UTF-8') .'" your confirmation.');
}

//$this->_sendConfirmationCode($member->get('username'), $email, $confirm, $member->get('registerDate'),$member->get('name'));


Event::trigger('onUserAfterChangeEmail', array($member->toArray()));
}
Expand Down Expand Up @@ -1757,7 +1769,7 @@ public function saveTask()
* @param string $confirm Confirmation code
* @return boolean
*/
private function _sendConfirmationCode($login, $email, $confirm)
private function _sendConfirmationCode($login, $email, $confirm, $name, $registerDate)
{
// Email subject
$subject = Config::get('sitename') .' account email confirmation';
Expand All @@ -1767,12 +1779,15 @@ private function _sendConfirmationCode($login, $email, $confirm)
'name' => 'emails',
'layout' => 'confirm'
));

$eview->set('option', $this->_option)
->set('sitename', Config::get('sitename'))
->set('login', $login)
->set('email', $email)
->set('confirm', $confirm)
->set('baseURL', Request::base());
->set('baseURL', Request::base())
->set('registerDate', $registerDate)
->set('name', $name);

$message = $eview->loadTemplate();
$message = str_replace("\n", "\r\n", $message);
Expand Down

0 comments on commit 41ca54c

Please sign in to comment.