1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 11:14:12 +02:00

Fix issue processwire/processwire-issues#1839 which corrects ProcessLogin refresh issue when client and server have different times for UTC/GMT.

This commit is contained in:
Ryan Cramer
2023-11-14 09:51:33 -05:00
parent c1df78b0a6
commit 260e0f228e
2 changed files with 8 additions and 3 deletions

View File

@@ -13,8 +13,13 @@ $(document).ready(function() {
}
$("#login_hidpi").val(hidpi ? 1 : 0);
var startTime = parseInt($('#login_start').val()); // GMT/UTC
var maxSeconds = 300; // max age for login form before refreshing it (300=5min)
var maxSeconds = 300, // max age for login form before refreshing it (300=5min)
queryMatch = location.search.toString().match(/[?&]r=(\d+)/), // match from query string
queryTime = (queryMatch ? parseInt(queryMatch[1]) : 0), // query string time ?r=123456789
clientTime = Math.floor(new Date().getTime() / 1000), // client UTC time
serverTime = parseInt($('#login_start').val()), // server UTC time
requestTime = (queryTime > serverTime ? queryTime : serverTime), // request time
startTime = (requestTime > clientTime ? clientTime : requestTime); // determined start time
// force refresh of login form if 5 minutes go by without activity
var watchTime = function() {

View File

@@ -1 +1 @@
$(document).ready(function(){if(window.devicePixelRatio>1){var hidpi=true}else{var media="(-webkit-min-device-pixel-ratio: 1.5), "+"(min--moz-device-pixel-ratio: 1.5), "+"(-o-min-device-pixel-ratio: 3/2), "+"(min-resolution: 1.5dppx)";var hidpi=window.matchMedia&&window.matchMedia(media).matches}$("#login_hidpi").val(hidpi?1:0);var startTime=parseInt($("#login_start").val());var maxSeconds=300;var watchTime=function(){var ts=Math.floor((new Date).getTime()/1e3);var elapsedSeconds=ts-startTime;if(elapsedSeconds>maxSeconds){window.location.href="./?r="+ts}};watchTime();var interval=setInterval(watchTime,5e3);$("#login_name, #login_pass").on("keydown",function(){clearInterval(interval);interval=setInterval(watchTime,5e3)});$("#ProcessLoginForm").on("submit",function(){var $html=$("html");var touch=$html.data("whatintent")=="touch"||$html.data("whatinput")=="touch";clearInterval(interval);$("#login_touch").val(touch?1:0);$("#login_width").val($(window).width())})});
$(document).ready(function(){if(window.devicePixelRatio>1){var hidpi=true}else{var media="(-webkit-min-device-pixel-ratio: 1.5), "+"(min--moz-device-pixel-ratio: 1.5), "+"(-o-min-device-pixel-ratio: 3/2), "+"(min-resolution: 1.5dppx)";var hidpi=window.matchMedia&&window.matchMedia(media).matches}$("#login_hidpi").val(hidpi?1:0);var maxSeconds=300,queryMatch=location.search.toString().match(/[?&]r=(\d+)/),queryTime=queryMatch?parseInt(queryMatch[1]):0,clientTime=Math.floor((new Date).getTime()/1e3),serverTime=parseInt($("#login_start").val()),requestTime=queryTime>serverTime?queryTime:serverTime,startTime=requestTime>clientTime?clientTime:requestTime;var watchTime=function(){var ts=Math.floor((new Date).getTime()/1e3);var elapsedSeconds=ts-startTime;if(elapsedSeconds>maxSeconds){window.location.href="./?r="+ts}};watchTime();var interval=setInterval(watchTime,5e3);$("#login_name, #login_pass").on("keydown",function(){clearInterval(interval);interval=setInterval(watchTime,5e3)});$("#ProcessLoginForm").on("submit",function(){var $html=$("html");var touch=$html.data("whatintent")=="touch"||$html.data("whatinput")=="touch";clearInterval(interval);$("#login_touch").val(touch?1:0);$("#login_width").val($(window).width())})});