diff --git a/js/ajax.js b/js/ajax.js index f484d522a7..55a74ce316 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -358,6 +358,19 @@ var AJAX = { return; } if (typeof data.success !== 'undefined' && data.success) { + + if(typeof data.user_changed !== 'undefined' && data.user_changed == 1) { + window.location.reload(); + PMA_ajaxShowMessage("Loading...", false); + AJAX.active = false; + AJAX.xhr = null; + return; + } else if(typeof data.logged_in !== 'undefined' && data.logged_in == 1) { + if($("#modalOverlay")) { + $("#modalOverlay").remove(); + } + } + $('html, body').animate({ scrollTop: 0 }, 'fast'); PMA_ajaxRemoveMessage(AJAX.$msgbox); @@ -411,6 +424,7 @@ var AJAX = { .not('#pma_demo') .not('#pma_console_container') .not('#prefs_autoload') + .not("#modalOverlay") .remove(); // Replace #page_content with new content if (data.message && data.message.length > 0) { @@ -505,6 +519,45 @@ var AJAX = { } AJAX._callback = function () {}; }); + } else if(typeof data.logged_in !== 'undefined' && data.logged_in == 0) { + // window.location.reload(); + // console.log(data.error) + PMA_ajaxRemoveMessage(AJAX.$msgbox); + AJAX.scriptHandler.reset(function(){ + if (data._selflink) { + var source = data._selflink.split('?')[0]; + // Check for faulty links + $selflink_replace = { + 'import.php': 'tbl_sql.php', + 'tbl_chart.php': 'sql.php', + 'tbl_gis_visualization.php': 'sql.php' + }; + if ($selflink_replace[source]) { + var replacement = $selflink_replace[source]; + data._selflink = data._selflink.replace(source, replacement); + } + $('#selflink').find('> a').attr('href', data._selflink); + } + if (data._params) { + PMA_commonParams.setAll(data._params); + } + if (data._scripts) { + AJAX.scriptHandler.load(data._scripts); + } + if (data._selflink && data._scripts && data._menuHash && data._params) { + if (! (history && history.pushState)) { + PMA_MicroHistory.add( + data._selflink, + data._scripts, + data._menuHash, + data._params, + AJAX.source.attr('rel') + ); + } + } + }); + $("#modalOverlay").replaceWith(data.error); + // alert("asdf"); } else { PMA_ajaxShowMessage(data.error, false); AJAX.active = false; diff --git a/js/functions.js b/js/functions.js index f3a66b5a13..6ad3b8f542 100644 --- a/js/functions.js +++ b/js/functions.js @@ -949,7 +949,8 @@ AJAX.registerOnload('functions.js', function () { 'server' : PMA_commonParams.get('server'), 'db' : PMA_commonParams.get('db'), 'guid': guid, - 'access_time':_idleSecondsCounter + 'access_time': _idleSecondsCounter, + 'check_timeout': 1 }; $.ajax({ type: 'POST', @@ -972,13 +973,20 @@ AJAX.registerOnload('functions.js', function () { // max value for setInterval() function interval = Math.min((remaining - 1) * 1000, Math.pow(2, 31) - 1); } + // console.log(_idleSecondsCounter); updateTimeout = window.setTimeout(UpdateIdleTime, interval); } else { // timeout occurred clearInterval(IncInterval); if (isStorageSupported('sessionStorage')) { window.sessionStorage.clear(); } - window.location.reload(true); + // window.location.reload(true); + if ($("#modalOverlay").length) { + $("#modalOverlay").replaceWith(data.error); + } else { + $('body').append(data.error); + } + _idleSecondsCounter = 0; } } }); diff --git a/libraries/classes/Plugins/Auth/AuthenticationCookie.php b/libraries/classes/Plugins/Auth/AuthenticationCookie.php index 0120bda179..ffaa0c15a1 100644 --- a/libraries/classes/Plugins/Auth/AuthenticationCookie.php +++ b/libraries/classes/Plugins/Auth/AuthenticationCookie.php @@ -86,13 +86,24 @@ class AuthenticationCookie extends AuthenticationPlugin global $conn_error; $response = Response::getInstance(); - if ($response->loginPage()) { + $xyz = isset($_REQUEST['check_timeout']) || isset($_REQUEST['login_aftertimeout']); + if (!$xyz && $response->loginPage()) { if (defined('TESTSUITE')) { return true; } else { exit; } } + if($xyz) { + $response->setRequestStatus(false); + } + + if(isset($_REQUEST['login_aftertimeout'])) { + $response->addJSON( + 'logged_in', + 0 + ); + } // No recall if blowfish secret is not configured as it would produce // garbage @@ -108,9 +119,7 @@ class AuthenticationCookie extends AuthenticationPlugin // skip the IE autocomplete feature. $autocomplete = ' autocomplete="off"'; } - - echo $this->template->render('login/header', ['theme' => $GLOBALS['PMA_Theme']]); - + echo $this->template->render('login/header', ['theme' => $GLOBALS['PMA_Theme'], 'add_class' => $xyz ? ' modal_form' : '', 'check_timeout' => $xyz ? 1 : 0]); if ($GLOBALS['cfg']['DBG']['demo']) { echo '