From 24751780ccd349f10ce6db3787cb0e2a33924efc Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Mon, 14 Oct 2013 16:23:59 +1100 Subject: [PATCH] Fix: CurrentUserId returned domain --- Disco.Services/Users/UserService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Disco.Services/Users/UserService.cs b/Disco.Services/Users/UserService.cs index ae69628e..6d24a233 100644 --- a/Disco.Services/Users/UserService.cs +++ b/Disco.Services/Users/UserService.cs @@ -37,17 +37,26 @@ namespace Disco.Services.Users { get { + string userId; + // Check for ASP.NET if (HttpContext.Current != null) { if (HttpContext.Current.Request.IsAuthenticated) - return HttpContext.Current.User.Identity.Name; + userId = HttpContext.Current.User.Identity.Name; else return null; } + else + { + // User default User + userId = System.Security.Principal.WindowsIdentity.GetCurrent().Name; + } - // User default User - return System.Security.Principal.WindowsIdentity.GetCurrent().Name; + if (userId.Contains("\\")) + return userId.Substring(checked(userId.IndexOf("\\") + 1)); + else + return userId; } }