FIX better url for get conf with REST API
need to be more userfriendly and similar to other api (without a variable with GET varible in URL "?confname="
This commit is contained in:
parent
e7360279b5
commit
6a53e02c3c
@ -1409,15 +1409,15 @@ class Setup extends DolibarrApi
|
||||
*
|
||||
* Note that conf variables that stores security key or password hashes can't be loaded with API.
|
||||
*
|
||||
* @url GET /conf
|
||||
*
|
||||
* @param string $confname Name of conf variable to get
|
||||
* @param string $constante Name of conf variable to get
|
||||
* @return array|mixed Data without useless information
|
||||
*
|
||||
* @url GET conf/{constante}
|
||||
*
|
||||
* @throws RestException 403 Forbidden
|
||||
* @throws RestException 500 Error Bad or unknown value for constname
|
||||
* @throws RestException 500 Error Bad or unknown value for constname
|
||||
*/
|
||||
public function getConf($confname)
|
||||
public function getConf($constante)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -1426,14 +1426,14 @@ class Setup extends DolibarrApi
|
||||
throw new RestException(403, 'Error API open to admin users only or to the login user defined with constant API_LOGIN_ALLOWED_FOR_ADMIN_CHECK');
|
||||
}
|
||||
|
||||
if (! preg_match('/^[a-zA-Z0-9_]+$/', $confname) || ! isset($conf->global->$confname)) {
|
||||
if (! preg_match('/^[a-zA-Z0-9_]+$/', $constante) || ! isset($conf->global->$constante)) {
|
||||
throw new RestException(500, 'Error Bad or unknown value for constname');
|
||||
}
|
||||
if (preg_match('/(_pass|password|secret|_key|key$)/i', $confname)) {
|
||||
if (preg_match('/(_pass|password|secret|_key|key$)/i', $constante)) {
|
||||
throw new RestException(403, 'Forbidden');
|
||||
}
|
||||
|
||||
return $conf->global->$confname;
|
||||
return $conf->global->$constante;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user