Additional check for the provided user props via the API
This commit is contained in:
parent
bd6ab1c7fe
commit
5a52bde05a
3 changed files with 33 additions and 3 deletions
|
@ -87,11 +87,16 @@ class Admins extends API_V1_Controller {
|
||||||
$admin = $request->get_body();
|
$admin = $request->get_body();
|
||||||
$this->parser->decode($admin);
|
$this->parser->decode($admin);
|
||||||
|
|
||||||
if (isset($admin['id']))
|
if (array_key_exists('id', $admin))
|
||||||
{
|
{
|
||||||
unset($admin['id']);
|
unset($admin['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! array_key_exists('settings', $admin))
|
||||||
|
{
|
||||||
|
throw new Exception('No settings property provided.');
|
||||||
|
}
|
||||||
|
|
||||||
$id = $this->admins_model->add($admin);
|
$id = $this->admins_model->add($admin);
|
||||||
|
|
||||||
// Fetch the new object from the database and return it to the client.
|
// Fetch the new object from the database and return it to the client.
|
||||||
|
|
|
@ -87,11 +87,26 @@ class Providers extends API_V1_Controller {
|
||||||
$provider = $request->get_body();
|
$provider = $request->get_body();
|
||||||
$this->parser->decode($provider);
|
$this->parser->decode($provider);
|
||||||
|
|
||||||
if (isset($provider['id']))
|
if (array_key_exists('id', $provider))
|
||||||
{
|
{
|
||||||
unset($provider['id']);
|
unset($provider['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! array_key_exists('services', $provider))
|
||||||
|
{
|
||||||
|
throw new Exception('No services property provided.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! array_key_exists('settings', $provider))
|
||||||
|
{
|
||||||
|
throw new Exception('No settings property provided.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! array_key_exists('working_plan', $provider['settings']['working_plan']))
|
||||||
|
{
|
||||||
|
$provider['settings']['working_plan'] = $this->settings_model->get_setting('company_working_plan');
|
||||||
|
}
|
||||||
|
|
||||||
$id = $this->providers_model->add($provider);
|
$id = $this->providers_model->add($provider);
|
||||||
|
|
||||||
// Fetch the new object from the database and return it to the client.
|
// Fetch the new object from the database and return it to the client.
|
||||||
|
|
|
@ -87,11 +87,21 @@ class Secretaries extends API_V1_Controller {
|
||||||
$secretary = $request->get_body();
|
$secretary = $request->get_body();
|
||||||
$this->parser->decode($secretary);
|
$this->parser->decode($secretary);
|
||||||
|
|
||||||
if (isset($secretary['id']))
|
if (array_key_exists('id', $secretary))
|
||||||
{
|
{
|
||||||
unset($secretary['id']);
|
unset($secretary['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! array_key_exists('providers', $secretary))
|
||||||
|
{
|
||||||
|
throw new Exception('No providers property provided.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! array_key_exists('settings', $secretary))
|
||||||
|
{
|
||||||
|
throw new Exception('No settings property provided.');
|
||||||
|
}
|
||||||
|
|
||||||
$id = $this->secretaries_model->add($secretary);
|
$id = $this->secretaries_model->add($secretary);
|
||||||
|
|
||||||
// Fetch the new object from the database and return it to the client.
|
// Fetch the new object from the database and return it to the client.
|
||||||
|
|
Loading…
Reference in a new issue