Skip to content

Commit

Permalink
Show a message about pending email verification on the profile page.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Mar 22, 2021
1 parent 9bac1ab commit 7da514d
Showing 1 changed file with 41 additions and 15 deletions.
56 changes: 41 additions & 15 deletions module/VuFind/src/VuFind/Controller/MyResearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ public function profileAction()
$view->accountDeletion
= !empty($config->Authentication->account_deletion);

$this->addPendingEmailChangeMessage($user);

return $view;
}

Expand Down Expand Up @@ -2046,21 +2048,7 @@ public function changeEmailAction()
$this->flashMessenger()
->addMessage('change_email_verification_reminder', 'info');
}
if (!empty($user->pending_email)) {
$url = $this->url()->fromRoute('myresearch-emailnotverified')
. '?reverify=true';
$this->flashMessenger()->addMessage(
[
'html' => true,
'msg' => 'email_change_pending_html',
'tokens' => [
'%%pending%%' => $user->pending_email,
'%%url%%' => $url,
],
],
'info'
);
}
$this->addPendingEmailChangeMessage($user);
return $view;
}

Expand Down Expand Up @@ -2258,4 +2246,42 @@ protected function collectRequestAccountStats(array $records): ?array
}
return $accountStatus;
}

/**
* Add a message about any pending email change to the flash messenger
*
* @param \VuFind\Db\Row\User $user User
*
* @return void
*/
protected function addPendingEmailChangeMessage($user)
{
if (!empty($user->pending_email)) {
// Check if the message has already been added
foreach ($this->flashMessenger()->getInfoMessages() as $message) {
if (is_array($message)) {
$msg = $message['msg'] ?? '';
if ('email_change_pending_html' === $msg) {
return;
}
}
}

$url = $this->url()->fromRoute(
'myresearch-emailnotverified',
[],
['query' => ['reverify' => 'true']]
);
$this->flashMessenger()->addInfoMessage(
[
'html' => true,
'msg' => 'email_change_pending_html',
'tokens' => [
'%%pending%%' => $user->pending_email,
'%%url%%' => $url,
],
]
);
}
}
}

0 comments on commit 7da514d

Please sign in to comment.