NEW More information on the user credential section

This commit is contained in:
Laurent Destailleur 2025-08-16 05:22:04 +02:00
parent 6cf4174b22
commit 6fd796d5bf
2 changed files with 41 additions and 33 deletions

View file

@ -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

View file

@ -1969,8 +1969,9 @@ if ($action == 'create' || $action == 'adduserldap') {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder tableforfield centpercent">';
// Title line
print '<tr class="liste_titre"><th class="liste_titre">';
print img_picto('', 'security', 'class="paddingleft pictofixedwidth"').$langs->trans("Security");
print img_picto('', 'security', 'class="paddingleft pictofixedwidth"').$langs->trans("SecurityForConnection");
print '</th>';
print '<th class="liste_titre right">';
if (getDolGlobalString('MAIN_SECURITY_ALLOW_TOTP') && $permissiontoeditpasswordandsee) {
@ -1994,16 +1995,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print '</td>';
print "</tr>\n";
// Alternative email for OAUth2 login
if (!empty($object->email_oauth2) && preg_match('/googleoauth/', $dolibarr_main_authentication)) {
print '<tr class="nooddeven"><td class="titlefieldmiddle">'.$langs->trans("AlternativeEmailForOAuth2").'</td>';
print '<td>';
print dol_print_email($object->email_oauth2);
print '</td>';
print "</tr>\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 .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
} else {
if ($user->admin && $user->id == $object->id) {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
$valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
$valuetoshow .= '<!-- Encrypted into '.$object->pass_indatabase_crypted.' -->';
} else {
$valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
$valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
}
}
}
*/
// 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 '</tr>'."\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 '<tr class="nooddeven">';
print '<td class="titlefieldmiddle">'.$langs->trans("OAUTH_ID");
print ' '.ucfirst($nameofservice).' ';
print '</td>';
print '<td>';
$constoauthlogin = 'OAUTH_'.strtoupper($nameofservice).'-Login_ID';
if (getDolGlobalString($constoauthlogin)) {
print getDolGlobalString($constoauthlogin);
}
print '</td>';
print "</tr>\n";
// Alternative email for OAuth2 login
if (!empty($object->email_oauth2)) {
print '<tr class="nooddeven"><td class="titlefieldmiddle">'.$langs->trans("AlternativeEmailForOAuth2").'</td>';
print '<td>';
print dol_print_email($object->email_oauth2);
print '</td>';
print "</tr>\n";
}
}
}
// Token for API
if (isModEnabled('api') && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) {
print '<tr class="nooddeven"><td>'.$langs->trans("ApiKey").'</td>';
print '<td>';
@ -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 '</span>';
}
if (getDolGlobalString('API_ENABLE_COUNT_CALLS')) {
print ' &nbsp; <span class="badge badge-info" title="'.$langs->trans("TotalAPICall").'">'.getDolUserInt('API_COUNT_CALL').'</span>';
}
print '</td></tr>';
}
// Show private information about login
if ((getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 0) || (getDolGlobalInt('MAIN_ENABLE_LOGINS_PRIVACY') == 1 && $object->id == $user->id)) {
print '<tr class="nooddeven"><td>'.$langs->trans("LastConnexion").'</td>';
print '<td>';
@ -2086,6 +2091,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print '</td>';
print "</tr>\n";
}
print '</table>';
print '</div>';