From b72c8ef953f3a552a459d2c2e255429fbfb871ab Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Sun, 30 Apr 2017 10:15:53 +0200 Subject: [PATCH] Get userId more easily - also changed the default to -1 just in case we can't determine the Id (at least then changes won't be "blamed" on user 0 --- src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs b/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs index 122193973d..d23804b8fc 100644 --- a/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs +++ b/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Web; using Umbraco.Core.Security; @@ -43,11 +44,8 @@ namespace Umbraco.Core.Auditing /// protected int GetCurrentRequestBackofficeUserId() { - var userId = 0; - if (HttpContext.Current == null) return userId; - var owinContext = HttpContext.Current.GetOwinContext(); - if (owinContext == null) return userId; - var backOfficeIdentity = owinContext.Authentication.User.GetUmbracoIdentity(); + var userId = -1; + var backOfficeIdentity = Thread.CurrentPrincipal.GetUmbracoIdentity(); if (backOfficeIdentity != null) int.TryParse(backOfficeIdentity.Id.ToString(), out userId); return userId;