[0005266] Fixed timeouts in ajax contexts.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 14 Dec 2020 08:32:52 +0000 (09:32 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 14 Dec 2020 08:35:27 +0000 (09:35 +0100)
access/login.php
includes/session.inc
js/inserts.js
js/login.js
js/reports.js

index a390006fbbe9284c876bee571450eea18e4710a3..e8e28975de06fc62f19b0efd327253aad52f862a 100644 (file)
@@ -20,6 +20,7 @@ function defaultCompany()
        document.forms[0].company_login_name.options[".user_company()."].selected = true;
 }
 </script>";
+
        add_js_file('login.js');
        // Display demo user name and password within login form if allow_demo_mode option is true
        if ($SysPrefs->allow_demo_mode == true)
@@ -66,6 +67,7 @@ function defaultCompany()
        {
                echo $js;
        }
+
        echo "</head>\n";
 
        echo "<body id='loginscreen' $onload>\n";
@@ -85,7 +87,6 @@ function defaultCompany()
        } 
        echo "</td>\n";
        end_row();
-
        if (!$login_timeout)
                table_section_title(_("Version")." $version   Build ".$SysPrefs->build_version." - "._("Login"));
        $value = $login_timeout ? $_SESSION['wa_current_user']->loginname : ($SysPrefs->allow_demo_mode ? "demouser":"");
@@ -111,14 +112,14 @@ function defaultCompany()
                } else {
                        text_row(_("Company"), "company_login_nickname", "", 20, 50);
                }
-               start_row();
-               label_cell($demo_text, "colspan=2 align='center' id='log_msg'");
-               end_row();
        }; 
+       start_row();
+       label_cell($demo_text, "colspan=2 align='center' id='log_msg'");
+       end_row();
        end_table(1);
        echo "<input type='hidden' id=ui_mode name='ui_mode' value='".!fallback_mode()."' >\n";
        echo "<center><input type='submit' value='&nbsp;&nbsp;"._("Login -->")."&nbsp;&nbsp;' name='SubmitUser'"
-               ." onclick='set_fullmode();'".(isset($blocked_msg) ? " disabled" : '')." ></center>\n";
+               ." onclick='".(in_ajax() ? 'retry();': 'set_fullmode();')."'".(isset($blocked_msg) ? " disabled" : '')." ></center>\n";
 
        foreach($_SESSION['timeout']['post'] as $p => $val) {
                // add all request variables to be resend together with login data
@@ -131,7 +132,7 @@ function defaultCompany()
                                        echo "<input type='hidden' name='{$p}[$i]' value='$v'>";
        }
        end_form(1);
-       $Ajax->addScript(true, "document.forms[0].password.focus();");
+       $Ajax->addScript(true, "if (document.forms.length) document.forms[0].password.focus();");
 
     echo "<script language='JavaScript' type='text/javascript'>
     //<![CDATA[
index 71206521fda2bd2d89471b85e868862fed4b4e99..e87f8bf187b75acd6c56f66c0805bfc19aa7cade 100644 (file)
@@ -133,15 +133,13 @@ function kill_login()
 function login_fail()
 {
        global $path_to_root;
-       
+
        header("HTTP/1.1 401 Authorization Required");
        echo "<center><br><br><font size='5' color='red'><b>" . _("Incorrect Password") . "<b></font><br><br>";
        echo "<b>" . _("The user and password combination is not valid for the system.") . "<b><br><br>";
-
        echo _("If you are not an authorized user, please contact your system administrator to obtain an account to enable you to use the system.");
        echo "<br><a href='$path_to_root/index.php'>" . _("Try again") . "</a>";
        echo "</center>";
-
        kill_login();
        die();
 }
@@ -533,9 +531,10 @@ if (!defined('FA_LOGOUT_PHP_FILE')){
                                        '', html_specials_encode($_SERVER['REQUEST_URI'])),
                                'post' => $_POST);
 
+               if (in_ajax())
+                       $Ajax->popup($path_to_root ."/access/timeout.php");
+               else
                        include($path_to_root . "/access/login.php");
-                       if (in_ajax())
-                               $Ajax->activate('_page_body');
                        exit;
                } else {
                        if (isset($_POST["company_login_nickname"]) && !isset($_POST["company_login_name"])) {
@@ -555,7 +554,11 @@ if (!defined('FA_LOGOUT_PHP_FILE')){
                        if (!$succeed)
                        {
                        // Incorrect password
-                               login_fail();
+                               if (isset($_SESSION['timeout'])) {
+                                       include($path_to_root . "/access/login.php");
+                                       exit;
+                               } else
+                                       login_fail();
                        }
                        elseif(isset($_SESSION['timeout']) && !$_SESSION['timeout']['post'])
                        {
index d0722250769dcb4d3cb25be45586979d34f77f23..0c40deb8e8f5c51b091293a2fce6c8b757773b07 100644 (file)
@@ -580,7 +580,7 @@ function setHotKeys() {
                        ev.returnValue = false;
                        return false;
                }
-               if (editors!=='undefined' && editors[key]) {
+               if (editors!==undefined && editors[key]) {
                        callEditor(key);
                        return stopEv(ev); // prevent default binding
                }
index e4f0c68133d09d09a7adfd1a55881827dfb01279..7e4f3fd4ace92693e6de6b7e7696521e4013103b 100644 (file)
@@ -31,3 +31,9 @@ function set_fullmode() {
        document.loginform.submit();
        return true;
 }
+
+function retry() {
+       document.getElementById('ui_mode').value = 1;
+       JsHttpRequest.request(this);
+       return true;
+}
index bd7d0a438ab93bce485b722b1551d995cf72564b..332a9cae9135db4e06f8fa62fa1605803799b3ca 100644 (file)
@@ -35,12 +35,6 @@ var replinks = {
                        return false;
                }
        },
-       'button': function(e) {
-               e.onclick = function() {
-                       window.open('', 'formpopup', 'toolbar=no,scrollbars=yes,resizable=yes,menubar=no');
-                       e.form.target='formpopup';
-               }
-       },
 }
 
 function set_options(e)