ldap update
This commit is contained in:
@@ -6,6 +6,7 @@ require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\KeycloakAuth;
|
||||
use App\LdapProvisioner;
|
||||
use App\UserSelfManagementService;
|
||||
use Desktop\AppRegistry;
|
||||
use Desktop\AppVisibility;
|
||||
@@ -29,6 +30,8 @@ $auth = new KeycloakAuth($keycloakConfig);
|
||||
$registry = new AppRegistry($projectRoot . '/config/apps.php');
|
||||
$widgetRegistry = new WidgetRegistry($projectRoot . '/config/widgets.php');
|
||||
$service = new UserSelfManagementService($projectRoot);
|
||||
$registrationConfig = ConfigLoader::load($projectRoot, 'registration');
|
||||
$ldap = new LdapProvisioner($registrationConfig);
|
||||
$isAuthenticated = $auth->isAuthenticated();
|
||||
$authUser = $isAuthenticated && is_array($_SESSION['desktop_auth']['user'] ?? null)
|
||||
? $_SESSION['desktop_auth']['user']
|
||||
@@ -58,6 +61,22 @@ $after = $service->save($decoded, $authUser, $visibleApps, $widgets, $skins);
|
||||
$payload = $service->buildBootstrapPayload($authUser, $visibleApps, $widgets, $skins);
|
||||
$payload['preferences'] = $after;
|
||||
$payload['meta']['requires_reload'] = requiresReload($before, $after);
|
||||
$payload['meta']['ldap_profile_sync'] = [
|
||||
'attempted' => false,
|
||||
'success' => false,
|
||||
'message' => 'LDAP-Sync nicht ausgefuehrt.',
|
||||
];
|
||||
|
||||
$username = trim((string) ($authUser['username'] ?? ''));
|
||||
if ($username !== '' && $ldap->isEnabled()) {
|
||||
$payload['meta']['ldap_profile_sync']['attempted'] = true;
|
||||
$ldapResult = $ldap->updateUserProfile($username, is_array($after['profile'] ?? null) ? $after['profile'] : []);
|
||||
$payload['meta']['ldap_profile_sync']['success'] = (bool) ($ldapResult['success'] ?? false);
|
||||
$payload['meta']['ldap_profile_sync']['message'] = (string) ($ldapResult['message'] ?? 'LDAP-Sync ohne Rueckmeldung.');
|
||||
if (isset($ldapResult['updated_fields']) && is_array($ldapResult['updated_fields'])) {
|
||||
$payload['meta']['ldap_profile_sync']['updated_fields'] = array_values(array_map('strval', $ldapResult['updated_fields']));
|
||||
}
|
||||
}
|
||||
|
||||
respond($payload);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user