From 5637dd2f3f57147465f7e416251ff10b34279575 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Feb 2024 16:15:08 +0100 Subject: [PATCH] Fix do not use oauth if link was not clicked --- htdocs/main.inc.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9b15733c4cf..7386d9d54b1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -841,11 +841,17 @@ if (!defined('NOLOGIN')) { if ($test && $goontestloop && (GETPOST('actionlogin', 'aZ09') == 'login' || $dolibarr_main_authentication != 'dolibarr')) { // Loop on each test mode defined into $authmode // $authmode is an array for example: array('0'=>'dolibarr', '1'=>'googleoauth'); - if (in_array('googleoauth', $authmode)) { - if (GETPOST('beforeoauthloginredirect') != 'google') { + $oauthmodetotestarray = array('google'); + foreach ($oauthmodetotestarray as $oauthmodetotest) { + if (in_array($oauthmodetotest.'oauth', $authmode) && GETPOST('beforeoauthloginredirect') != $oauthmodetotest) { // If we did not click on the link to use OAuth authentication, we do not try it. dol_syslog("User did not click on link for OAuth so we disable check using googleoauth"); - unset($authmode['googleoauth']); + foreach ($authmode as $tmpkey => $tmpval) { + if ($tmpval == $oauthmodetotest.'oauth') { + unset($authmode[$tmpkey]); + break; + } + } } }