Only one IUserEventHandler, or multiple?

Topics: Customizing Orchard
Jul 7, 2015 at 11:37 PM
Edited Jul 7, 2015 at 11:44 PM
I've created my own implementation of IUserEventHandler, with the intention of doing additional work during the LoggedOut and LoggedIn events. This is with Orchard 1.9.0.

Although my implementation's LoggedOut method is getting called when the user logs out, the LoggedIn method is not getting called when the user logs in successfully.

I've also got the Orchard.Users.Workflows featured enabled.

Is it necessary to use Orchard.SuppressDependency to allow my custom implementation to execute? So only one can be used?

The other classes which depend upon this interface are taking one IUserEventHandler as the dependency, rather than a collection. Is this by design, and if so, why is it not a good idea to support multiple IUserEventHandlers?

Thanks.
Jul 7, 2015 at 11:54 PM
Never mind.

I was using a Dynamic Form for login, and so the only way to trigger a user event with the dynamic form is to use the IUserEventHandler included with Orchard.Users.Workflows.

On a related note: Pro tip: Ensure the Name property of your custom workflow activity (Task) has no blank spaces, or it will cause the workflow editor to fail.
Developer
Jul 8, 2015 at 9:43 AM
So you are using the SiginUserActivity to actually login the user, correct? Perhaps it would be a good enhancement to trigger the IUSerEventHandler.LoggedIn event from this activity.

And just to clarify some of your previous questions, this article sheds some light on how event handlers work and why you see classes inject a single IUserEventHandler rather than an enumerable: http://www.ideliverable.com/blog/ieventhandler
Jul 31, 2015 at 8:08 PM
sfmskywalker wrote:
So you are using the SiginUserActivity to actually login the user, correct? Perhaps it would be a good enhancement to trigger the IUSerEventHandler.LoggedIn event from this activity.
Yes, I agree wholeheartedly. This way, no matter how a user logs in, the event handlers will fire consistently.
And just to clarify some of your previous questions, this article sheds some light on how event handlers work and why you see classes inject a single IUserEventHandler rather than an enumerable: http://www.ideliverable.com/blog/ieventhandler
Thanks for the tip.
Developer
Aug 3, 2015 at 10:54 AM
You're welcome.
Would you mind creating an issue for this on GitHub (if none already exists for this topic)? Thanks!
Sep 30, 2015 at 11:24 PM