Skip to content
Snippets Groups Projects
Verified Commit 9891cda4 authored by Damien's avatar Damien
Browse files

FEAT #10886 TIME 0:30 delete ldap configuration

parent aa525523
No related branches found
No related tags found
No related merge requests found
...@@ -61,21 +61,20 @@ class ConfigurationController ...@@ -61,21 +61,20 @@ class ConfigurationController
return $response->withStatus(400)->withJson(['errors' => 'Configuration does not exist']); return $response->withStatus(400)->withJson(['errors' => 'Configuration does not exist']);
} }
if ($configuration['identifier'] == 'emailServer' && !PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_email_configuration'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
} elseif ($configuration['identifier'] == 'ldapServer' && !PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_connections'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
$configuration['value'] = json_decode($configuration['value'], true); $configuration['value'] = json_decode($configuration['value'], true);
if ($configuration['identifier'] == 'emailServer') { if ($configuration['identifier'] == 'emailServer') {
if (!empty($configuration['value']['password'])) { if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_email_configuration'])) {
$configuration['value']['password'] = ''; return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
$configuration['value']['passwordAlreadyExists'] = true; }
} else { $configuration['value']['passwordAlreadyExists'] = !empty($configuration['value']['password']);
$configuration['value']['passwordAlreadyExists'] = false; $configuration['value']['password'] = '';
} elseif ($configuration['identifier'] == 'ldapServer') {
if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_connections'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
} }
$ldapConfigurations = ConfigurationModel::getByIdentifier(['identifier' => 'ldapServer', 'select' => [1]]);
$configuration['count'] = count($ldapConfigurations);
} }
return $response->withJson(['configuration' => $configuration]); return $response->withJson(['configuration' => $configuration]);
...@@ -276,8 +275,17 @@ class ConfigurationController ...@@ -276,8 +275,17 @@ class ConfigurationController
if ($configuration['identifier'] == 'emailServer' && !PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_email_configuration'])) { if ($configuration['identifier'] == 'emailServer' && !PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_email_configuration'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
} elseif ($configuration['identifier'] == 'ldapServer' && !PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_connections'])) { } elseif ($configuration['identifier'] == 'ldapServer') {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']); if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_connections'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
$ldapConfigurations = ConfigurationModel::getByIdentifier(['identifier' => 'ldapServer', 'select' => [1]]);
if (count($ldapConfigurations) == 1) {
$connectionConfiguration = ConfigurationModel::getByIdentifier(['identifier' => 'connection', 'select' => ['value']]);
if ($connectionConfiguration[0]['value'] == '"ldap"') {
return $response->withStatus(400)->withJson(['errors' => 'Ldap connection is activated']);
}
}
} elseif ($configuration['identifier'] == 'connection') { } elseif ($configuration['identifier'] == 'connection') {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment