diff --git a/lib/App/Module/Contracts/SessionProvider.php b/lib/App/Module/Contracts/SessionProvider.php index a49706f..c297702 100644 --- a/lib/App/Module/Contracts/SessionProvider.php +++ b/lib/App/Module/Contracts/SessionProvider.php @@ -22,5 +22,5 @@ interface SessionProvider /** * Remove session keys owned by this module (called on logout). */ - public function clear(): void; + public function clear(AppContainer $container): void; } diff --git a/lib/Service/Auth/AuthSessionTenantContextService.php b/lib/Service/Auth/AuthSessionTenantContextService.php index f87afe0..1658692 100644 --- a/lib/Service/Auth/AuthSessionTenantContextService.php +++ b/lib/Service/Auth/AuthSessionTenantContextService.php @@ -54,7 +54,7 @@ class AuthSessionTenantContextService public function clearModuleSessionData(): void { foreach ($this->moduleSessionProviders() as $provider) { - $provider->clear(); + $provider->clear($this->container); } } diff --git a/modules/addressbook/lib/Module/AddressBook/Providers/AddressBookSessionProvider.php b/modules/addressbook/lib/Module/AddressBook/Providers/AddressBookSessionProvider.php index 0a8e525..f09f983 100644 --- a/modules/addressbook/lib/Module/AddressBook/Providers/AddressBookSessionProvider.php +++ b/modules/addressbook/lib/Module/AddressBook/Providers/AddressBookSessionProvider.php @@ -15,15 +15,23 @@ final class AddressBookSessionProvider implements SessionProvider { public function populate(array $user, AppContainer $container): void { - $userId = (int) ($user['id'] ?? 0); - if ($userId <= 0) { - unset($_SESSION['module.addressbook.departments_by_tenant']); + $sessionStore = $container->get(SessionStoreInterface::class); + if (!$sessionStore instanceof SessionStoreInterface) { return; } - $tenantContext = $container->get(UserTenantContextService::class); - $sessionStore = $container->get(SessionStoreInterface::class); - if (!$tenantContext instanceof UserTenantContextService || !$sessionStore instanceof SessionStoreInterface) { + $userId = (int) ($user['id'] ?? 0); + if ($userId <= 0) { + $sessionStore->remove('module.addressbook.departments_by_tenant'); + return; + } + + try { + $tenantContext = $container->get(UserTenantContextService::class); + } catch (\Throwable) { + return; + } + if (!$tenantContext instanceof UserTenantContextService) { return; } @@ -33,8 +41,11 @@ final class AddressBookSessionProvider implements SessionProvider ); } - public function clear(): void + public function clear(AppContainer $container): void { - unset($_SESSION['module.addressbook.departments_by_tenant']); + $sessionStore = $container->get(SessionStoreInterface::class); + if ($sessionStore instanceof SessionStoreInterface) { + $sessionStore->remove('module.addressbook.departments_by_tenant'); + } } } diff --git a/modules/bookmarks/lib/Module/Bookmarks/Providers/BookmarksSessionProvider.php b/modules/bookmarks/lib/Module/Bookmarks/Providers/BookmarksSessionProvider.php index bcbea96..38b772e 100644 --- a/modules/bookmarks/lib/Module/Bookmarks/Providers/BookmarksSessionProvider.php +++ b/modules/bookmarks/lib/Module/Bookmarks/Providers/BookmarksSessionProvider.php @@ -13,23 +13,30 @@ final class BookmarksSessionProvider implements SessionProvider public function populate(array $user, AppContainer $container): void { - $userId = (int) ($user['id'] ?? 0); - if ($userId <= 0) { - unset($_SESSION[self::SESSION_KEY]); + $sessionStore = $container->get(SessionStoreInterface::class); + if (!$sessionStore instanceof SessionStoreInterface) { + return; + } + + $userId = (int) ($user['id'] ?? 0); + if ($userId <= 0) { + $sessionStore->remove(self::SESSION_KEY); return; } - $sessionStore = $container->get(SessionStoreInterface::class); $bookmarkService = $container->get(BookmarkService::class); - if (!$sessionStore instanceof SessionStoreInterface || !$bookmarkService instanceof BookmarkService) { + if (!$bookmarkService instanceof BookmarkService) { return; } $sessionStore->set(self::SESSION_KEY, $bookmarkService->listGroupedForUser($userId)); } - public function clear(): void + public function clear(AppContainer $container): void { - unset($_SESSION[self::SESSION_KEY]); + $sessionStore = $container->get(SessionStoreInterface::class); + if ($sessionStore instanceof SessionStoreInterface) { + $sessionStore->remove(self::SESSION_KEY); + } } } diff --git a/modules/notifications/i18n/default_de.json b/modules/notifications/i18n/default_de.json index c5002ad..1aa9fd7 100644 --- a/modules/notifications/i18n/default_de.json +++ b/modules/notifications/i18n/default_de.json @@ -5,6 +5,8 @@ "Mark as read": "Als gelesen markieren", "Dismiss": "Verwerfen", "Action failed": "Aktion fehlgeschlagen", + "Loading notifications…": "Benachrichtigungen werden geladen…", + "Failed to load notifications": "Benachrichtigungen konnten nicht geladen werden", "New user: %s": "Neuer Benutzer: %s", "User deleted: %s": "Benutzer gelöscht: %s", "User activated: %s": "Benutzer aktiviert: %s", diff --git a/modules/notifications/i18n/default_en.json b/modules/notifications/i18n/default_en.json index 5a2c464..76bcf93 100644 --- a/modules/notifications/i18n/default_en.json +++ b/modules/notifications/i18n/default_en.json @@ -5,6 +5,8 @@ "Mark as read": "Mark as read", "Dismiss": "Dismiss", "Action failed": "Action failed", + "Loading notifications…": "Loading notifications…", + "Failed to load notifications": "Failed to load notifications", "New user: %s": "New user: %s", "User deleted: %s": "User deleted: %s", "User activated: %s": "User activated: %s", diff --git a/modules/notifications/lib/Module/Notifications/Providers/NotificationsSessionProvider.php b/modules/notifications/lib/Module/Notifications/Providers/NotificationsSessionProvider.php index 324823b..f53fa1f 100644 --- a/modules/notifications/lib/Module/Notifications/Providers/NotificationsSessionProvider.php +++ b/modules/notifications/lib/Module/Notifications/Providers/NotificationsSessionProvider.php @@ -13,15 +13,19 @@ final class NotificationsSessionProvider implements SessionProvider public function populate(array $user, AppContainer $container): void { - $userId = (int) ($user['id'] ?? 0); - if ($userId <= 0) { - unset($_SESSION[self::SESSION_KEY]); + $sessionStore = $container->get(SessionStoreInterface::class); + if (!$sessionStore instanceof SessionStoreInterface) { + return; + } + + $userId = (int) ($user['id'] ?? 0); + if ($userId <= 0) { + $sessionStore->remove(self::SESSION_KEY); return; } - $sessionStore = $container->get(SessionStoreInterface::class); $service = $container->get(NotificationService::class); - if (!$sessionStore instanceof SessionStoreInterface || !$service instanceof NotificationService) { + if (!$service instanceof NotificationService) { return; } @@ -30,8 +34,11 @@ final class NotificationsSessionProvider implements SessionProvider $sessionStore->set(self::SESSION_KEY, $service->unreadCount($userId, $tenantId > 0 ? $tenantId : null)); } - public function clear(): void + public function clear(AppContainer $container): void { - unset($_SESSION[self::SESSION_KEY]); + $sessionStore = $container->get(SessionStoreInterface::class); + if ($sessionStore instanceof SessionStoreInterface) { + $sessionStore->remove(self::SESSION_KEY); + } } } diff --git a/modules/notifications/templates/topbar-notification-bell.phtml b/modules/notifications/templates/topbar-notification-bell.phtml index 9edaba0..9b7e588 100644 --- a/modules/notifications/templates/topbar-notification-bell.phtml +++ b/modules/notifications/templates/topbar-notification-bell.phtml @@ -26,6 +26,14 @@ $unreadCount = (int) ($notifNav['unread_count'] ?? 0);