Merge pull request #3282 from elarifr/develop-userapikey

fix user role and store fake api_key if api module no enabled
This commit is contained in:
Laurent Destailleur 2015-07-19 23:28:36 +02:00
commit d08a1ec116

View File

@ -10,6 +10,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -825,7 +826,8 @@ if (($action == 'create') || ($action == 'adduserldap'))
}
print '</td></tr>';
if(! empty($conf->api->enabled)) {
if(! empty($conf->api->enabled))
{
// API key
$generated_api_key = '';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
@ -836,6 +838,13 @@ if (($action == 'create') || ($action == 'adduserldap'))
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
print '</td></tr>';
}
else
{
// PARTIAL WORKAROUND
$generated_fake_api_key=getRandomPassword(false);
print '<input type="hidden" name="api_key" value="'.$generated_fake_api_key.'">';
}
// Administrator
if (! empty($user->admin))
@ -880,7 +889,6 @@ if (($action == 'create') || ($action == 'adduserldap'))
}
print "</td></tr>\n";
}
}
// Type
print '<tr><td>'.$langs->trans("Type").'</td>';