diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 1cacd70d602..4b70419630f 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -69,8 +69,6 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Validation of login/pass/entity with standard modules if (empty($login)) { - unset($_SESSION["dol_loginmesg"]); - $test = true; foreach ($authmode as $mode) { if ($test && $mode && !$login) { @@ -113,7 +111,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Load translation files required by the page $langs->loadLangs(array('other', 'main', 'errors')); - $_SESSION["dol_loginmesg"] = (isset($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"].', ' : '').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode); + $_SESSION["dol_loginmesg"] = (empty($_SESSION["dol_loginmesg"]) ? '' : $_SESSION["dol_loginmesg"].', ').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode); } } } diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index eabfe389174..e1180c980ef 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -604,7 +604,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); print __METHOD__." login=".$login."\n"; - $this->assertEquals($login, ''); // Expected '' because should failed because login 'auto' does not exists + $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists } /**