Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Avi 4 posts 84 karma points
    Mar 03, 2022 @ 11:50
    Avi
    0

    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

  • Avi 4 posts 84 karma points
    Apr 06, 2022 @ 08:57
    Avi
    0

    Hello again,

    Just bumping this up if anyone has some insights.

    Thanks

  • Ambert van Unen 175 posts 819 karma points c-trib
    Apr 06, 2022 @ 11:44
    Ambert van Unen
    0

    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?

Please Sign in or register to post replies

Write your reply to:

Draft