From 61d97ccd22abfc9fd60bce6741b7cf4e1d2047bf Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Fri, 5 Nov 2021 16:02:24 +0100 Subject: [PATCH] NEW : redirect after connection in login page --- htdocs/core/lib/security2.lib.php | 5 +++++ htdocs/core/tpl/login.tpl.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index ab47bc02899..d6546e64cfd 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -224,6 +224,11 @@ if (!function_exists('dol_loginfunction')) { $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $moreloginextracontent = $hookmanager->resPrint; + //Redirect after connection + $parameters = array('entity' => GETPOST('entity', 'int')); + $reshook = $hookmanager->executeHooks('redirectAfterConnection', $parameters); // Note that $action and $object may have been modified by some hooks. + $php_self = $hookmanager->resPrint; + // Login $login = (!empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin)); $password = $demopassword; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 0a4bb149986..9f2f2f68712 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -57,7 +57,7 @@ if (!empty($conf->dol_use_jmobile)) { $conf->use_javascript_ajax = 1; } -$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); +$php_self = empty($php_self) ? dol_escape_htmltag($_SERVER['PHP_SELF']) : $php_self; $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''; if (!preg_match('/mainmenu=/', $php_self)) { $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home';