Changeset 2274


Ignore:
Timestamp:
Mar 7, 2014, 2:27:06 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #587: Improve session timeout handling

A really, really big red error message is used on the main page. When clicking the error message a login prompt is displayed. Once the user is logged in again, the error message is removed and navigation is restored.

Location:
extensions/net.sf.basedb.reggie/branches/2.15-stable/resources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/2.15-stable/resources/css/reggie.css

    r2244 r2274  
    11@charset "UTF-8";
     2
     3#timeoutMessage
     4{
     5  position: absolute;
     6  display: table-cell;
     7  top: 15%;
     8  bottom: 15%;
     9  left: 15%;
     10  right: 15%;
     11  font-weight: bold;
     12  padding-top: 15%;
     13  text-align: center;
     14  font-size: 2em;
     15}
     16
    217
    318.error a
  • extensions/net.sf.basedb.reggie/branches/2.15-stable/resources/keep_session_alive.jsp

    r1897 r2274  
    2222function init()
    2323{
     24  // Dispatch an event to the 'timeoutMessage' <div> asking it to restore navigation buttons
     25  var timeoutMessage = window.opener.document.getElementById('timeoutMessage');
     26  var customEvent = timeoutMessage.ownerDocument.createEvent('CustomEvent');
     27  customEvent.initCustomEvent('logged-in', true, true, {});
     28  timeoutMessage.dispatchEvent(customEvent);
     29  // Close this window
    2430  window.close();
    2531}
  • extensions/net.sf.basedb.reggie/branches/2.15-stable/resources/reggie.js

    r2215 r2274  
    543543  var internal = {};
    544544  internal.h1 = document.getElementsByTagName('h1')[0];
     545  internal.navigation = document.getElementsByClassName('navigation')[0];
    545546  internal.interval = debug ? 5000 : 30000;
    546547  internal.root = reggieRoot ? reggieRoot : '';
     
    580581    request.send(null);
    581582   
    582     setTimeout(internal.repeatAgain, 1000);
     583    internal.timerId = setTimeout(internal.repeatAgain, 1000); 
    583584  }
    584585 
     
    586587  {
    587588    Main.removeClass(internal.h1, 'working');
    588     setTimeout(internal.sendKeepAlive, internal.interval);
     589    internal.timerId = setTimeout(internal.sendKeepAlive, internal.interval);
    589590  }
    590591 
     
    600601    if (!response.session)
    601602    {
    602       var keepAlive = Main.getPageValue('open.windows', 'KeepSessionAlive');
    603       if (!keepAlive || keepAlive.closed)
     603      // Session has timed out; no need to keep it running
     604      clearTimeout(internal.timerId);
     605
     606      // Hide navigation buttons
     607      internal.navigation.style.display = 'none';
     608     
     609      // Show message
     610      var div = document.getElementById('timeoutMessage');
     611      if (!div)
    604612      {
    605         Main.openPopup(internal.root+'keep_session_alive.jsp?ID='+ID, 'KeepSessionAlive', 800, 600);
     613        div = document.createElement('div');
     614        div.id = 'timeoutMessage';
     615        div.className = 'messagecontainer error link';
     616        div.innerHTML = 'You have been logged out due to inactivity or unstable internet connection. Click HERE to login again!';
     617        div.addEventListener('click', internal.openLoginWindow, false);
     618        div.addEventListener('logged-in', internal.loggedInAgain, false);
     619        var frm = document.forms['reggie'];
     620        frm.appendChild(div);
    606621      }
    607     }
     622      else
     623      {
     624        Main.show('timeoutMessage');
     625      }
     626    }
     627  }
     628 
     629  // Open popup window for logging in again
     630  internal.openLoginWindow = function()
     631  {
     632    Main.openPopup(internal.root+'keep_session_alive.jsp?ID='+ID, 'KeepSessionAlive', 800, 600);
     633  }
     634 
     635  // Callback when the user has been successfully logged in
     636  internal.loggedInAgain = function()
     637  {
     638    Main.hide('timeoutMessage');
     639    internal.navigation.style.display = 'block';
     640    internal.repeatAgain();
    608641  }
    609642 
Note: See TracChangeset for help on using the changeset viewer.