The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit abfa6300 authored by Demian Katz's avatar Demian Katz
Browse files

Fixed faulty followup logic.

- Improved comments for greater clarity.
- Resolves PR #130.
parent b12f4501
No related merge requests found
......@@ -67,7 +67,10 @@ class MyResearchController extends AbstractBase
/**
* Store a referer (if appropriate) to keep post-login redirect pointing
* to an appropriate location.
* to an appropriate location. This is used when the user clicks the
* log in link from an arbitrary page or when a password is mistyped;
* separate logic is used for storing followup information when VuFind
* forces the user to log in from another context.
*
* @return void
*/
......@@ -78,16 +81,12 @@ class MyResearchController extends AbstractBase
if (empty($referer)) {
return;
}
// Normalize the referer URL so that inconsistencies in protocol
// and trailing slashes do not break comparisons; this same normalization
// is applied to all URLs examined below.
$refererNorm = trim(end(explode('://', $referer, 2)), '/');
$refererNorm = $this->normalizeUrlForComparison($referer);
// If the referer lives outside of VuFind, don't store it! We only
// want internal post-login redirects.
$baseUrl = $this->url()->fromRoute('home');
$baseUrlNorm = trim(end(explode('://', $baseUrl, 2)), '/');
$baseUrl = $this->getServerUrl('home');
$baseUrlNorm = $this->normalizeUrlForComparison($baseUrl);
if (0 !== strpos($refererNorm, $baseUrlNorm)) {
return;
}
......@@ -95,8 +94,8 @@ class MyResearchController extends AbstractBase
// If the referer is the MyResearch/Home action, it probably means
// that the user is repeatedly mistyping their password. We should
// ignore this and instead rely on any previously stored referer.
$myResearchHomeUrl = $this->url()->fromRoute('myresearch-home');
$mrhuNorm = trim(end(explode('://', $myResearchHomeUrl, 2)), '/');
$myResearchHomeUrl = $this->getServerUrl('myresearch-home');
$mrhuNorm = $this->normalizeUrlForComparison($myResearchHomeUrl);
if ($mrhuNorm === $refererNorm) {
return;
}
......@@ -105,6 +104,20 @@ class MyResearchController extends AbstractBase
$this->followup()->store(array(), $referer);
}
/**
* Normalize the referer URL so that inconsistencies in protocol and trailing
* slashes do not break comparisons.
*
* @param string $url URL to normalize
*
* @return string
*/
protected function normalizeUrlForComparison($url)
{
$parts = explode('://', $url, 2);
return trim(end($parts), '/');
}
/**
* Prepare and direct the home page where it needs to go
*
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment