Skip to content

Commit

Permalink
Fix email-based catalog login from record holdings tab. (vufind-org#3030
Browse files Browse the repository at this point in the history
)
  • Loading branch information
EreMaijala authored Aug 14, 2023
1 parent 09faad7 commit bf01976
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
17 changes: 9 additions & 8 deletions module/VuFind/src/VuFind/Auth/EmailAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ public function __construct(
*
* Stores the required information in the session.
*
* @param string $email Email address to send the link to
* @param array $data Information from the authentication request (such as
* user details)
* @param array $urlParams Default parameters for the generated URL
* @param string $linkRoute The route to use as the base url for the login link
* @param string $subject Email subject
* @param string $template Email message template
* @param string $email Email address to send the link to
* @param array $data Information from the authentication request (such as user details)
* @param array $urlParams Default parameters for the generated URL
* @param string $linkRoute The route to use as the base url for the login link
* @param array $routeParams Route parameters
* @param string $subject Email subject
* @param string $template Email message template
*
* @return void
*/
Expand All @@ -156,6 +156,7 @@ public function sendAuthenticationLink(
$data,
$urlParams,
$linkRoute = 'myresearch-home',
$routeParams = [],
$subject = 'email_login_subject',
$template = 'Email/login-link.phtml'
) {
Expand Down Expand Up @@ -191,7 +192,7 @@ public function sendAuthenticationLink(
$urlParams['hash'] = $hash;
$viewParams = $linkData;
$viewParams['url'] = $serverHelper(
$urlHelper($linkRoute, [], ['query' => $urlParams])
$urlHelper($linkRoute, $routeParams, ['query' => $urlParams])
);
$viewParams['title'] = $this->config->Site->title;

Expand Down
13 changes: 8 additions & 5 deletions module/VuFind/src/VuFind/Auth/ILSAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ public function newCatalogLogin($username, $password)
/**
* Send email authentication link
*
* @param string $email Email address
* @param string $route Route for the login link
* @param string $email Email address
* @param string $route Route for the login link
* @param array $routeParams Route parameters
* @param array $urlParams URL parameters
*
* @return void
*/
public function sendEmailLoginLink($email, $route)
public function sendEmailLoginLink($email, $route, $routeParams = [], $urlParams = [])
{
if (null === $this->emailAuthenticator) {
throw new \Exception('Email authenticator not set');
Expand All @@ -187,8 +189,9 @@ public function sendEmailLoginLink($email, $route)
$this->emailAuthenticator->sendAuthenticationLink(
$patron['email'],
$patron,
['auth_method' => 'ILS'],
$route
['auth_method' => 'ILS'] + $urlParams,
$route,
$routeParams
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion module/VuFind/src/VuFind/Controller/AbstractBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ protected function catalogLogin()
$routeMatch = $this->getEvent()->getRouteMatch();
$routeName = $routeMatch ? $routeMatch->getMatchedRouteName()
: 'myresearch-profile';
$ilsAuth->sendEmailLoginLink($username, $routeName);
$routeParams = $routeMatch ? $routeMatch->getParams() : [];
$ilsAuth->sendEmailLoginLink($username, $routeName, $routeParams, ['catalogLogin' => 'true']);
$this->flashMessenger()
->addSuccessMessage('email_login_link_sent');
} else {
Expand Down

0 comments on commit bf01976

Please sign in to comment.