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:
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.
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.
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:
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:
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.
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
Hello again,
Just bumping this up if anyone has some insights.
Thanks
If you have the ID you could always inject the IBackOfficeUserManager to get the name/emailadress of the ID you had by using
FindByIdAsyc(id)
?Or perhaps you could use inject IBackOfficeSecurity so you can access the CurrentUser with all its properties?
is working on a reply...