-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Closed
Copy link
Labels
Milestone
Description
When creating a user account via the user management web ui, the '\OCP\User\Events\UserCreatedEvent' is emitted twice.
Steps to reproduce
- Create a listener for the '\OCP\User\Events\UserCreatedEvent' event and let it log or do something
- Create a user via the user management webui
- See the handle function of the listener is called twice
Expected behaviour
'\OCP\User\Events\UserCreatedEvent' should be emitted once only.
Actual behaviour
'\OCP\User\Events\UserCreatedEvent' is emitted twice.
Server configuration
Tested in official docker based Nextcloud 19.0.4 and 20.0.1
I think this causes the behaviour:
- Emit Hook and Event in UserManager:
server/lib/private/User/Manager.php
Lines 375 to 378 in f94af85
if ($user instanceof IUser) { $this->emit('\OC\User', 'postCreateUser', [$user, $password]); $this->eventDispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); } - React on Hook and emit Event a second time:
Lines 539 to 546 in f94af85
$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { /** @var \OC\User\User $user */ \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->get(IEventDispatcher::class); $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); });
If commenting L544-L545of Server.php the listener is only triggerd once.