From 097036154fc4c3fdaac28695a13146a25b109816 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Wed, 24 Feb 2016 13:46:38 -0500
Subject: [PATCH] [VUFIND-1149] Don't mess up the login lightbox if the user
 has already logged in in another browser tab or window.

---
 .../src/VuFind/Controller/MyResearchController.php       | 5 +++++
 themes/bootstrap3/js/lightbox.js                         | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php
index ce4ca61e9f8..3ff17ebcccc 100644
--- a/module/VuFind/src/VuFind/Controller/MyResearchController.php
+++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php
@@ -228,6 +228,11 @@ class MyResearchController extends AbstractBase
     {
         // Don't log in if already logged in!
         if ($this->getAuthManager()->isLoggedIn()) {
+            if ($this->inLightbox()) {
+                $response = $this->getResponse();
+                $response->setStatusCode(205);
+                return $response;
+            }
             return $this->redirect()->toRoute('home');
         }
         $this->clearFollowupUrl();
diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js
index 4c4f0d3c7fa..45dbcd28eb9 100644
--- a/themes/bootstrap3/js/lightbox.js
+++ b/themes/bootstrap3/js/lightbox.js
@@ -243,7 +243,14 @@ var Lightbox = {
       url:url,
       data:post
     })
-    .done(callback)
+    .done(function(data, textStatus, jqXHR) {
+        if (jqXHR.status == 205) {
+            // No reload since any post params would cause a prompt
+            window.location.href = window.location.href;
+        } else {
+            callback(data, textStatus, jqXHR);
+        }
+    })
     .fail(function(response, textStatus) {
       console.log(response, textStatus); // Error reporting
       console.log(url, post);
-- 
GitLab