From 6fd796d5bfc58ae3e004aadca68d63af56d33c16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Aug 2025 05:22:04 +0200 Subject: [PATCH] NEW More information on the user credential section --- htdocs/langs/en_US/admin.lang | 4 +- htdocs/user/card.php | 70 +++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5585ff700e2..8ec3a949831 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1963,7 +1963,7 @@ ApiDesc=By enabling this module, Dolibarr become a REST server to provide miscel ApiProductionMode=Enable production mode (this will activate use of a cache for services management) ApiExporerIs=You can explore and test the APIs at URL OnlyActiveElementsAreExposed=Only elements from enabled modules are exposed -ApiKey=Key for API +ApiKey=Token for API WarningAPIExplorerDisabled=The API explorer has been disabled. API explorer is not required to provide API services. It is a tool for developer to find/test REST APIs. If you need this tool, go into setup of module API REST to activate it. ##### Bank ##### BankSetupModule=Bank module setup @@ -2707,3 +2707,5 @@ MainSecurityPolicySucesfullyRemoved=Content Security Policy successfully removed MainErrorRemovingSecurityPolicy=An error occurred when trying to remove a Content Security Policy MainSecurityPolicySucesfullyAdded=Content Security Policy successfully added MainErrorAddingSecurityPolicy=An error occurred when trying to add a Content Security Policy +SecurityForConnection=Credentials for connexion +AddCredential=Add a credential diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 26f0662289d..35310941ae2 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1969,8 +1969,9 @@ if ($action == 'create' || $action == 'adduserldap') { print '
'; print ''; + // Title line print ''; print '\n"; - // Alternative email for OAUth2 login - if (!empty($object->email_oauth2) && preg_match('/googleoauth/', $dolibarr_main_authentication)) { - print ''; - print ''; - print "\n"; - } - - // Password + // Password for LDAP or HTTP Basic $valuetoshow = ''; if (preg_match('/ldap/', $dolibarr_main_authentication)) { if (!empty($object->ldap_sid)) { @@ -2023,25 +2015,8 @@ if ($action == 'create' || $action == 'adduserldap') { if (preg_match('/http/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword"); } - /* - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if ($object->pass) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); - $valuetoshow .= ''.$langs->trans("Hidden").''; - } else { - if ($user->admin && $user->id == $object->id) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); - $valuetoshow .= ''.$langs->trans("Hidden").''; - $valuetoshow .= ''; - } else { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); - $valuetoshow .= ''.$langs->trans("Hidden").''; - } - } - } - */ - // Other form for user password + // Other info for user password $parameters = array('valuetoshow' => $valuetoshow, 'caneditpasswordandsee' => $permissiontoeditpasswordandsee, 'caneditpasswordandsend' => $permissiontoeditpasswordandsend); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook > 0) { @@ -2058,7 +2033,38 @@ if ($action == 'create' || $action == 'adduserldap') { print ''."\n"; } - // API key + // Token for OAuth + $tmparrayofauthmode = explode(',', $dolibarr_main_authentication); + foreach ($tmparrayofauthmode as $tmpauthmode) { + $langs->load("oauth"); + + $tmpauthmode = trim($tmpauthmode); + if (preg_match('/oauth/', $tmpauthmode)) { + $nameofservice = preg_replace('/oauth/', '', $tmpauthmode); + print ''; + print ''; + print ''; + print "\n"; + + // Alternative email for OAuth2 login + if (!empty($object->email_oauth2)) { + print ''; + print ''; + print "\n"; + } + } + } + + // Token for API if (isModEnabled('api') && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) { print ''; print ''; } + // Show private information about login if ((getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) || (getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 1 && $object->id == $user->id)) { print ''; print ''; print "\n"; } + print '
'; - print img_picto('', 'security', 'class="paddingleft pictofixedwidth"').$langs->trans("Security"); + print img_picto('', 'security', 'class="paddingleft pictofixedwidth"').$langs->trans("SecurityForConnection"); print ''; if (getDolGlobalString('MAIN_SECURITY_ALLOW_TOTP') && $permissiontoeditpasswordandsee) { @@ -1994,16 +1995,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print "
'.$langs->trans("AlternativeEmailForOAuth2").''; - print dol_print_email($object->email_oauth2); - print '
'.$langs->trans("OAUTH_ID"); + print ' '.ucfirst($nameofservice).' '; + print ''; + $constoauthlogin = 'OAUTH_'.strtoupper($nameofservice).'-Login_ID'; + if (getDolGlobalString($constoauthlogin)) { + print getDolGlobalString($constoauthlogin); + } + print '
'.$langs->trans("AlternativeEmailForOAuth2").''; + print dol_print_email($object->email_oauth2); + print '
'.$langs->trans("ApiKey").''; @@ -2067,13 +2073,12 @@ if ($action == 'create' || $action == 'adduserldap') { print showValueWithClipboardCPButton($object->api_key, 1, $langs->transnoentities("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste print ''; } - if (getDolGlobalString('API_ENABLE_COUNT_CALLS')) { print '   '.getDolUserInt('API_COUNT_CALL').''; } - print '
'.$langs->trans("LastConnexion").''; @@ -2086,6 +2091,7 @@ if ($action == 'create' || $action == 'adduserldap') { print '
'; print '
';