Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set of email verification related tweaks #1891

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion module/VuFind/src/VuFind/Auth/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,12 @@ public function updateEmail(UserRow $user, $email)
// Depending on verification setting, either do a direct update or else
// put the new address into a pending state.
if ($this->config->Authentication->verify_email ?? false) {
$user->pending_email = $email;
// If new email address is the current address, just reset any pending
// email address:
$user->pending_email = ($email === $user->email) ? '' : $email;
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
} else {
$user->updateEmail($email, true);
$user->pending_email = '';
}
$user->save();
$this->updateSession($user);
Expand Down
46 changes: 31 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,32 @@ 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)) {
$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,
],
]
);
}
}
}