2
votes

When I save a Media file in umbraco I get the aftersave event but I don't know how can I get the current user in this context.

Events: http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events

I tried, but doesnt work: http://our.umbraco.org/forum/developers/extending-umbraco/5317-current-login-user

2

2 Answers

2
votes

I think it's just:

User currentUser = User.GetCurrent();

(I haven't tested it, though)

0
votes

If @Douglas Ludlow's solution does not work try this:

var userTicket = new System.Web.HttpContextWrapper(System.Web.HttpContext.Current).GetUmbracoAuthTicket();
if (userTicket != null)
{
    var currentUser = ApplicationContext.Current.Services.UserService.GetByUsername(userTicket.Name);
}