idleTimeout - Prośba o sprawdzenie |
idleTimeout - Prośba o sprawdzenie |
18.03.2018, 13:42:26
Post
#1
|
|
Grupa: Zarejestrowani Postów: 140 Pomógł: 0 Dołączył: 14.01.2017 Ostrzeżenie: (0%) |
Wielka prośba, aby pomóc mi znaleźć błąd w poniższym skrypcie
Problem polega na tym, że jak odblokuje interfejs i odświeżę stronę to mnie wylogowuje, dziwne bo skoro hasło zostało przyjęte po ID sesji i user_ID to nie powinno mnie wylogować. Jest tu jeszcze jeden bubel, ale nie ma to w tej chwili znaczenia, otóż muszę ajax request zrobić, aby zmienna zapisująca id bieżącej sesji była zapisywana w mysql jako json array, aby potem przy odblokowywaniu usuwać tylko jedno id z arraya a nie opróżniać cały, tak by działało to w kliku domenach jednocześnie.
końcówka skryptu [php] //----------- WARNING DIALOG FUNCTIONS --------------// openWarningDialog = function() { $('#blockUI').fadeIn(500); $('#user_info').html(currentConfig.userInfo); $.post('../php_function/user/user.php', { ajax_test: "user_session_frozen" }); $('#unblock_UI_confirm').click(function() { passVerification(this); }); console.log(timeIdleTimeout); // var dialogContent = "<div id='idletimer_warning_dialog'><p>" + currentConfig.dialogText + "</p><p style='display:inline'>" + currentConfig.dialogTimeRemaining + ": <div style='display:inline' id='countdownDisplay'></div></p></div>"; /* $(dialogContent).dialog({ buttons: [{ text: currentConfig.dialogStayLoggedInButton, click: function () { destroyWarningDialog(); stopDialogTimer(); startIdleTimer(); } }, { text: currentConfig.dialogLogOutNowButton, click: function () { logoutUser(); } } ], closeOnEscape: false, modal: true, title: currentConfig.dialogTitle, open: function () { $(this).closest('.ui-dialog').find('.ui-dialog-titlebar-close').hide(); } }); */ countdownDisplay(); document.title = currentConfig.dialogTitle; if (currentConfig.sessionKeepAliveTimer) { stopKeepSessionAlive(); } }; passVerification = function(elem) { event.preventDefault(); event.stopPropagation(); $.post('../php_function/user/user.php', $(elem).parents("form").serializeArray(), function(ret) { if (ret == true) { $.post('../php_function/user/user.php', { ajax_test: "user_session_unfrozen" }); console.log(dialogTimer); stopDialogTimer(); startIdleTimer(); destroyWarningDialog(); } if (ret == false) {} console.log(ret); startIdleTimer(); console.log(startIdleTimer()); }); }; checkDialogTimeout = function() { var timeDialogTimeout = (store.get('idleTimerLastActivity') + (currentConfig.idleTimeLimit * 1000) + (currentConfig.dialogDisplayLimit * 1000)); if (($.now() > timeDialogTimeout) || (store.get('idleTimerLoggedOut') === true)) { logoutUser(); } }; startDialogTimer = function() { dialogTimer = setInterval(checkDialogTimeout, (currentConfig.idleCheckHeartbeat * 1000)); }; stopDialogTimer = function() { clearInterval(dialogTimer); clearInterval(remainingTimer); }; isDialogOpen = function() { // var dialogOpen = $("#idletimer_warning_dialog").is(":visible"); var dialogOpen = $('#blockUI').css('display') == 'block'; if (dialogOpen === true) { $(document).on('keydown', function(e) { if (e.keyCode == 9 || e.which == 9) e.preventDefault(); if ((e.which || e.keyCode) == 116 || (e.which || e.keyCode) == 82) e.preventDefault(); }) return true; } $(document).unbind('keydown'); return false; }; destroyWarningDialog = function() { $('#blockUI').fadeOut(500); document.title = origTitle; if (currentConfig.sessionKeepAliveTimer) { startKeepSessionAlive(); } }; countdownDisplay = function() { var dialogDisplaySeconds = currentConfig.dialogDisplayLimit, mins, secs; remainingTimer = setInterval(function() { mins = Math.floor(dialogDisplaySeconds / 60); // minutes if (mins < 10) { mins = '0' + mins; } secs = dialogDisplaySeconds - (mins * 60); // seconds if (secs < 10) { secs = '0' + secs; } $('#countdownDisplay').html(mins + ':' + secs); dialogDisplaySeconds -= 1; }, 1000); }; //----------- LOGOUT USER FUNCTION --------------// logoutUser = function() { store.set('idleTimerLoggedOut', true); if (currentConfig.sessionKeepAliveTimer) { stopKeepSessionAlive(); } if (currentConfig.customCallback) { currentConfig.customCallback(); } if (currentConfig.redirectUrl) { window.location.href = currentConfig.redirectUrl; } }; return this.each(function() { if (store.enabled) { store.set('idleTimerLastActivity', $.now()); store.set('idleTimerLoggedOut', false); activityDetector(); if (currentConfig.sessionKeepAliveTimer) { startKeepSessionAlive(); } startIdleTimer(); } else { alert(currentConfig.errorAlertMessage); } }); }; }(jQuery)); [php] Niestety nie mogę tej końcówki umieścić w tagach, bo tekst jest za długi Problem prawdopodobnie leży w startDialogTimer i stopDialogTimer, bo w konsoli licznik się nie zeruje, ale nie potrafię tego ugryźć. Ten post edytował topcio 18.03.2018, 13:25:55 |
|
|
Wersja Lo-Fi | Aktualny czas: 24.04.2024 - 12:17 |