File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 5858use OCP \Group \Events \GroupDeletedEvent ;
5959use OCP \Group \Events \UserAddedEvent ;
6060use OCP \Group \Events \UserRemovedEvent ;
61+ use OCP \User \Events \PostLoginEvent ;
6162use OCP \User \Events \UserCreatedEvent ;
6263use OCP \User \Events \UserDeletedEvent ;
6364
@@ -87,6 +88,7 @@ public function register(IRegistrationContext $context): void {
8788 $ context ->registerEventListener (UserCreatedEvent::class, MountCacheService::class);
8889 $ context ->registerEventListener (UserAddedEvent::class, MountCacheService::class);
8990 $ context ->registerEventListener (UserRemovedEvent::class, MountCacheService::class);
91+ $ context ->registerEventListener (PostLoginEvent::class, MountCacheService::class);
9092
9193 $ context ->registerConfigLexicon (ConfigLexicon::class);
9294 }
Original file line number Diff line number Diff line change 2828use OCP \IGroupManager ;
2929use OCP \IUser ;
3030use OCP \IUserManager ;
31+ use OCP \User \Events \PostLoginEvent ;
3132use OCP \User \Events \UserCreatedEvent ;
3233
3334/**
3435 * Listens to config events and update the mounts for the applicable users
3536 *
36- * @template-implements IEventListener<StorageCreatedEvent|StorageDeletedEvent|StorageUpdatedEvent|BeforeGroupDeletedEvent|UserCreatedEvent|UserAddedEvent|UserRemovedEvent|Event>
37+ * @template-implements IEventListener<StorageCreatedEvent|StorageDeletedEvent|StorageUpdatedEvent|BeforeGroupDeletedEvent|UserCreatedEvent|UserAddedEvent|UserRemovedEvent|PostLoginEvent| Event>
3738 */
3839class MountCacheService implements IEventListener {
3940 private CappedMemoryCache $ storageRootCache ;
@@ -70,6 +71,9 @@ public function handle(Event $event): void {
7071 if ($ event instanceof UserCreatedEvent) {
7172 $ this ->addUser ($ event ->getUser ());
7273 }
74+ if ($ event instanceof PostLoginEvent) {
75+ $ this ->onLogin ($ event ->getUser ());
76+ }
7377 }
7478
7579
@@ -221,4 +225,14 @@ private function addUser(IUser $user): void {
221225 $ this ->registerForUser ($ user , $ storage );
222226 }
223227 }
228+
229+ /**
230+ * Since storage config can rely on login credentials, we might need to update the config
231+ */
232+ private function onLogin (IUser $ user ): void {
233+ $ storages = $ this ->storagesService ->getAllGlobalStorages ();
234+ foreach ($ storages as $ storage ) {
235+ $ this ->registerForUser ($ user , $ storage );
236+ }
237+ }
224238}
You can’t perform that action at this time.
0 commit comments