Skip to content

Commit 88675fe

Browse files
committed
fix: Problem-with-login-redirect | LOTS-58
1 parent ea983d1 commit 88675fe

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

module/LOTS/src/LOTS/Controller/MyResearchController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ public function homeAction()
294294
if ($this->getAuthManager()->isLoggedIn()) {
295295
$user = $this->getAuthManager()->isLoggedIn();
296296
setrawcookie("currentVufindUserHoldLibrary", $user["home_library"], 0, "/");
297-
setrawcookie("currentVufindUser", $user["username"], 0, "/");
298-
setcookie("currentVufindUserFirstName", $user["firstname"], 0, "/");
299-
setcookie("currentVufindUserLastName", $user["lastname"], 0, "/");
297+
setrawcookie("currentVufindUser", urlencode($user["username"]), 0, "/");
298+
setcookie("currentVufindUserFirstName", urlencode($user["firstname"]), 0, "/");
299+
setcookie("currentVufindUserLastName", urlencode($user["lastname"]), 0, "/");
300300
}
301301

302302
if ($this->params()->fromPost('processLogin')
@@ -322,7 +322,10 @@ public function homeAction()
322322
// Logged in? Forward user to followup action
323323
// or default action (if no followup provided):
324324
if ($url = $this->getFollowupUrl()) {
325-
$this->clearFollowupUrl();
325+
//$this->clearFollowupUrl();
326+
// LOTS-58
327+
$this->redirect()->toUrl($this->getFollowupUrl());
328+
326329
// If a user clicks on the "Your Account" link, we want to be sure
327330
// they get to their account rather than being redirected to an old
328331
// followup URL. We'll use a redirect=0 GET flag to indicate this:

themes/lots/templates/layout/layout.phtml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@
99
$user = $this->auth()->isLoggedIn();
1010
$matomoparrams['username']=$user["username"];
1111
setrawcookie("currentVufindUserHoldLibrary", $user["home_library"], 0, "/");
12-
setrawcookie("currentVufindUser", $user["username"], 0, "/");
12+
13+
// LOTS-58
14+
$forbiddenChars = ",; \t\r\n\013\014";
15+
$expiry = time() + 86400;
16+
if (strpbrk($user["username"], $forbiddenChars) !== false) {
17+
setrawcookie("currentVufindUser", urlencode($user["username"]), $expiry, "/");
18+
} else {
19+
setrawcookie("currentVufindUser", $user["username"], $expiry, "/");
20+
}
21+
1322
setcookie("currentVufindUserFirstName", $user["firstname"], 0, "/");
1423
setcookie("currentVufindUserLastName", $user["lastname"], 0, "/");
1524

25+
$justLoggedIn = isset($user["username"]);
26+
1627
$logedin_json='{"logedin":"true", "firstname": "'.$user["firstname"].'" , "lastname": "'.$user["lastname"].'", "username": "'.$user["username"].'", "library": "'.$user["home_library"].'"}';
1728
} else {
1829
$matomoparrams['username']="Unknown";
@@ -56,6 +67,7 @@
5667
);
5768
?>
5869

70+
5971
<?php
6072
$rtl = '';
6173
if ($this->layout()->rtl) {
@@ -69,9 +81,28 @@ echo $bodytag;
6981
?>
7082

7183

72-
73-
74-
84+
<?php if ($justLoggedIn): ?>
85+
<script>
86+
console.log('justLoggedIn passed');
87+
window.addEventListener('load', function() {
88+
setTimeout(function() {
89+
var loginElement = document.getElementById('loginLinkMobile');
90+
if (loginElement) {
91+
var link = loginElement.querySelector('a.my-lib-link-1');
92+
if (link) {
93+
console.log('chg to <?=$this->transEsc("Log Out")?>');
94+
link.href = "/vufind/MyResearch/Logout";
95+
link.textContent = "<?=$this->transEsc("Log Out")?>";
96+
} else {
97+
console.log('link not found');
98+
}
99+
} else {
100+
console.log('element loginLinkMobile not found');
101+
}
102+
}, 1500); // timeout
103+
});
104+
</script>
105+
<?php endif; ?>
75106

76107
<!--body class="template-dir-<?=$this->templateDir?> template-name-<?=$this->templateName?> <?=$this->layoutClass('offcanvas-row')?><?php if ($this->layout()->rtl): ?> rtl<?php endif; ?>">
77108
<!- -?php // Set up the search box -- there are three possible cases:

0 commit comments

Comments
 (0)