From bf0197659ea2f1335736c6a05b2d16e70352e035 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Mon, 14 Aug 2023 14:22:25 +0300 Subject: [PATCH] Fix email-based catalog login from record holdings tab. (#3030) --- .../src/VuFind/Auth/EmailAuthenticator.php | 17 +++++++++-------- .../VuFind/src/VuFind/Auth/ILSAuthenticator.php | 13 ++++++++----- .../src/VuFind/Controller/AbstractBase.php | 3 ++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php b/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php index 5f5d228b5a9..79ea26e7f62 100644 --- a/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php +++ b/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php @@ -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 */ @@ -156,6 +156,7 @@ public function sendAuthenticationLink( $data, $urlParams, $linkRoute = 'myresearch-home', + $routeParams = [], $subject = 'email_login_subject', $template = 'Email/login-link.phtml' ) { @@ -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; diff --git a/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php b/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php index 8f6b2e51c96..f902de597c2 100644 --- a/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php +++ b/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php @@ -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'); @@ -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 ); } } diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index 85d891f7ead..6b2f1d54f99 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -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 {