diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index c54c2eea389..924b72bf982 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -58,6 +58,7 @@ use OCP\Group\Events\BeforeGroupDeletedEvent; use OCP\Group\Events\GroupDeletedEvent; use OCP\Group\Events\UserAddedEvent; use OCP\Group\Events\UserRemovedEvent; +use OCP\User\Events\PostLoginEvent; use OCP\User\Events\UserCreatedEvent; use OCP\User\Events\UserDeletedEvent; @@ -87,6 +88,7 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide $context->registerEventListener(UserCreatedEvent::class, MountCacheService::class); $context->registerEventListener(UserAddedEvent::class, MountCacheService::class); $context->registerEventListener(UserRemovedEvent::class, MountCacheService::class); + $context->registerEventListener(PostLoginEvent::class, MountCacheService::class); $context->registerConfigLexicon(ConfigLexicon::class); } diff --git a/apps/files_external/lib/Service/MountCacheService.php b/apps/files_external/lib/Service/MountCacheService.php index e284bf156d1..3f0d5935827 100644 --- a/apps/files_external/lib/Service/MountCacheService.php +++ b/apps/files_external/lib/Service/MountCacheService.php @@ -28,12 +28,13 @@ use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; +use OCP\User\Events\PostLoginEvent; use OCP\User\Events\UserCreatedEvent; /** * Listens to config events and update the mounts for the applicable users * - * @template-implements IEventListener + * @template-implements IEventListener */ class MountCacheService implements IEventListener { private CappedMemoryCache $storageRootCache; @@ -70,6 +71,9 @@ class MountCacheService implements IEventListener { if ($event instanceof UserCreatedEvent) { $this->handleUserCreated($event->getUser()); } + if ($event instanceof PostLoginEvent) { + $this->onLogin($event->getUser()); + } } @@ -223,4 +227,14 @@ class MountCacheService implements IEventListener { $this->registerForUser($user, $storage); } } + + /** + * Since storage config can rely on login credentials, we might need to update the config + */ + private function onLogin(IUser $user): void { + $storages = $this->storagesService->getAllGlobalStorages(); + foreach ($storages as $storage) { + $this->registerForUser($user, $storage); + } + } }