Notifications (events) - how to get current backoffice user and how to get a user by id

Hi guys,

I’ve built an Umbraco 9 site for a client and he has some requests about logging actions that were made in the Back office. Stuff like:

  • Users Login/Logout
  • Failed login attempts
  • User changes (groups modified for an existing user, new users added, etc)

I see that most of this stuff already have events (notifications) I can hook into, but some required information is not available inside the notification object.

My questions are:

  1. How can I get the user name or email by ID inside the notification handler function? For example, I see that ‘UserLoginFailedNotification’ has the AffectedUserId property inside the notification object, but I need to log the actual user name. Same with successful login and logout.

  2. How can I get the current Backoffice user that has performed the action that triggered the notification (like user changes)?

Hopefully my questions are clear enough. I’m new to Umbraco and still haven’t learned the proper terminology.

Thanks!

Avi


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/108434-notifications-events-how-to-get-current-backoffice-user-and-how-to-get-a-user-by-id