diff --git a/ChangeLog b/ChangeLog index 9f1ae0857a26e41838cd6a159bc9e61bf1ea5c9a..22b1631390f50f6a74b0f0847d607d4ed500f748 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.7 compared to 3.6.* ***** For users: +- New: Match other auth system: Login can be done entering login or user + email (this open the road for SSO). - New: Agenda export by project #1967. - New: Increase length of thirdparty to 128 chars. - New: "Is Order shippable" icon #1975. diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index d15556783139024f24a6b6956cf377e4bad627f0..8e5a8b13ea9b16d5889b1dd7cf53915e81e54d44 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2007-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> * @@ -20,7 +20,7 @@ /** * \file htdocs/core/login/functions_dolibarr.php * \ingroup core - * \brief Authentication functions for Dolibarr mode + * \brief Authentication functions for Dolibarr mode (check user on login or email and check pass) */ @@ -50,13 +50,15 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= { // If test username/password asked, we define $test=false and $login var if ok, set $_SESSION["dol_loginmesg"] if ko $table = MAIN_DB_PREFIX."user"; - $usernamecol = 'login'; + $usernamecol1 = 'login'; + $usernamecol2 = 'email'; $entitycol = 'entity'; - $sql ='SELECT rowid, entity, pass, pass_crypted'; + $sql ='SELECT rowid, login, entity, pass, pass_crypted'; $sql.=' FROM '.$table; - $sql.=' WHERE '.$usernamecol." = '".$db->escape($usertotest)."'"; - $sql.=' AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")"; + $sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'"; + if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'"; + $sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")"; dol_syslog("functions_dolibarr::check_user_password_dolibarr", LOG_DEBUG); $resql=$db->query($sql); @@ -106,7 +108,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= // Password ok ? if ($passok) { - $login=$usertotest; + $login=$obj->login; } else { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6698866869e3c156d8f8bd10c54e62d99a637b2c..51fa2cdf1627c57537ccd7b94c8de4ec21efc95c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1414,6 +1414,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $loginhtmltext.='<u>'.$langs->trans("User").'</u>'; $loginhtmltext.='<br><b>'.$langs->trans("Name").'</b>: '.$user->getFullName($langs); $loginhtmltext.='<br><b>'.$langs->trans("Login").'</b>: '.$user->login; + $loginhtmltext.='<br><b>'.$langs->trans("EMail").'</b>: '.$user->email; $loginhtmltext.='<br><b>'.$langs->trans("Administrator").'</b>: '.yn($user->admin); $type=($user->societe_id?$langs->trans("External").$company:$langs->trans("Internal")); $loginhtmltext.='<br><b>'.$langs->trans("Type").'</b>: '.$type;