First implementation. To be tested
Signed-Off-By: Lakshay arora <arora.lakshya123@gmail.com>
This commit is contained in:
parent
13874a6937
commit
aae6ff4424
53
js/ajax.js
53
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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -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 '<fieldset>';
|
||||
echo '<legend>' , __('phpMyAdmin Demo Server') , '</legend>';
|
||||
@ -148,10 +157,13 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
<br />
|
||||
<!-- Login form -->
|
||||
<form method="post" id="login_form" action="index.php" name="login_form"' , $autocomplete ,
|
||||
' class="disableAjax login hide js-show">
|
||||
' class="' . ($xyz ? "" : "disableAjax hide ") . 'login js-show">
|
||||
<fieldset>
|
||||
<legend>';
|
||||
echo '<input type="hidden" name="set_session" value="', htmlspecialchars(session_id()), '" />';
|
||||
if($xyz) {
|
||||
echo '<input type="hidden" name="login_aftertimeout" value="1" />';
|
||||
}
|
||||
echo __('Log in');
|
||||
echo Util::showDocu('index');
|
||||
echo '</legend>';
|
||||
@ -236,8 +248,11 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
$GLOBALS['error_handler']->dispErrors();
|
||||
echo '</div>';
|
||||
}
|
||||
echo $this->template->render('login/footer');
|
||||
|
||||
echo $this->template->render('login/footer', ['check_timeout' => $xyz ? 1 : 0]);
|
||||
|
||||
echo Config::renderFooter();
|
||||
|
||||
if (! defined('TESTSUITE')) {
|
||||
exit;
|
||||
} else {
|
||||
@ -472,6 +487,7 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
{
|
||||
// Name and password cookies need to be refreshed each time
|
||||
// Duration = one month for username
|
||||
$user_changed = !hash_equals($_COOKIE['pmaUserHashed-' . $GLOBALS['server']], crypt($this->user, "SillYSAlTstRInG"));
|
||||
$this->storeUsernameCookie($this->user);
|
||||
|
||||
// Duration = as configured
|
||||
@ -480,28 +496,50 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
if (! isset($_POST['change_pw'])) {
|
||||
$this->storePasswordCookie($this->password);
|
||||
}
|
||||
// URL where to go:
|
||||
$redirect_url = './index.php';
|
||||
|
||||
// any parameters to pass?
|
||||
$url_params = array();
|
||||
if (strlen($GLOBALS['db']) > 0) {
|
||||
$url_params['db'] = $GLOBALS['db'];
|
||||
}
|
||||
if (strlen($GLOBALS['table']) > 0) {
|
||||
$url_params['table'] = $GLOBALS['table'];
|
||||
}
|
||||
// any target to pass?
|
||||
if (! empty($GLOBALS['target'])
|
||||
&& $GLOBALS['target'] != 'index.php'
|
||||
) {
|
||||
$url_params['target'] = $GLOBALS['target'];
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['login_aftertimeout'])) {
|
||||
$response = Response::getInstance();
|
||||
$response->addJSON(
|
||||
'logged_in',
|
||||
1
|
||||
);
|
||||
$response->addJSON(
|
||||
'success',
|
||||
1
|
||||
);
|
||||
if($user_changed) {
|
||||
$response->addJSON(
|
||||
'user_changed',
|
||||
1
|
||||
);
|
||||
}
|
||||
if (! defined('TESTSUITE')) {
|
||||
exit;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Set server cookies if required (once per session) and, in this case,
|
||||
// force reload to ensure the client accepts cookies
|
||||
if (! $GLOBALS['from_cookie']) {
|
||||
// URL where to go:
|
||||
$redirect_url = './index.php';
|
||||
|
||||
// any parameters to pass?
|
||||
$url_params = [];
|
||||
if (strlen($GLOBALS['db']) > 0) {
|
||||
$url_params['db'] = $GLOBALS['db'];
|
||||
}
|
||||
if (strlen($GLOBALS['table']) > 0) {
|
||||
$url_params['table'] = $GLOBALS['table'];
|
||||
}
|
||||
// any target to pass?
|
||||
if (! empty($GLOBALS['target'])
|
||||
&& $GLOBALS['target'] != 'index.php'
|
||||
) {
|
||||
$url_params['target'] = $GLOBALS['target'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear user cache.
|
||||
*/
|
||||
@ -542,6 +580,10 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
$this->_getEncryptionSecret()
|
||||
)
|
||||
);
|
||||
$GLOBALS['PMA_Config']->setCookie(
|
||||
'pmaUserHashed-' . $GLOBALS['server'],
|
||||
crypt($username, "SillYSAlTstRInG")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -598,7 +640,6 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
// needed for PHP-CGI (not need for FastCGI or mod-php)
|
||||
$response->header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
$response->header('Pragma: no-cache');
|
||||
|
||||
$this->showLoginForm();
|
||||
}
|
||||
|
||||
|
||||
@ -350,7 +350,7 @@ class Response
|
||||
unset($this->_JSON['message']);
|
||||
}
|
||||
|
||||
if ($this->_isSuccess) {
|
||||
if ($this->_isSuccess || (array_key_exists("logged_in", $this->_JSON) && $this->_JSON["logged_in"] == 0)) {
|
||||
$this->addJSON('_title', $this->getHeader()->getTitleTag());
|
||||
|
||||
if (isset($GLOBALS['dbi'])) {
|
||||
|
||||
@ -441,10 +441,11 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// load user preferences
|
||||
$GLOBALS['PMA_Config']->loadUserPreferences();
|
||||
|
||||
/* Tell tracker that it can actually work */
|
||||
Tracker::enable();
|
||||
Tracker::enable();
|
||||
@ -1 +1,4 @@
|
||||
</div>
|
||||
{% if check_timeout == true %}
|
||||
</div>
|
||||
{% endif %}
|
||||
@ -1,4 +1,7 @@
|
||||
<div class="container">
|
||||
{% if check_timeout == true %}
|
||||
<div id="modalOverlay">
|
||||
{% endif %}
|
||||
<div class="container{{ add_class }}">
|
||||
<a href="{{ Url_link('https://www.phpmyadmin.net/') }}" target="_blank" rel="noopener noreferrer" class="logo">
|
||||
<img src="{{ theme.getImgPath('logo_right.png', 'pma_logo.png') }}" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />
|
||||
</a>
|
||||
|
||||
@ -621,6 +621,15 @@ body#loginform div.container {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
div.container.overlay {
|
||||
text-align: center;
|
||||
position: fixed;
|
||||
top: 10%;
|
||||
left: 40%;
|
||||
background: #fff;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
form.login label {
|
||||
float: <?php echo $left; ?>;
|
||||
width: 10em;
|
||||
|
||||
@ -901,6 +901,24 @@ body#loginform div.container {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
div.container.modal_form {
|
||||
margin: 0 auto;
|
||||
width: 30em;
|
||||
text-align: center;
|
||||
background: #fff;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
div#modalOverlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
z-index: 900;
|
||||
}
|
||||
|
||||
form.login label {
|
||||
float: <?php echo $left; ?>;
|
||||
width: 10em;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user