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);
|
||||
|
||||
|
||||
@@ -345,11 +345,16 @@
|
||||
|
||||
const payload = await response.json();
|
||||
const after = payload.preferences;
|
||||
const ldapSync = payload.meta?.ldap_profile_sync || null;
|
||||
state.bootstrap = payload;
|
||||
state.draft = clone(after);
|
||||
state.success = payload.meta?.requires_reload
|
||||
const baseMessage = payload.meta?.requires_reload
|
||||
? 'Gespeichert. Desktop wird fuer Skin- oder App-Aenderungen neu geladen.'
|
||||
: 'Einstellungen wurden gespeichert.';
|
||||
const ldapMessage = ldapSync && ldapSync.attempted
|
||||
? ` LDAP: ${ldapSync.message || (ldapSync.success ? 'Synchronisiert.' : 'Nicht synchronisiert.')}`
|
||||
: '';
|
||||
state.success = `${baseMessage}${ldapMessage}`;
|
||||
state.saving = false;
|
||||
renderApp(root, state);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user