Fixes: U4-4696 Macro personalized cache with custom membership provider not working - for any membership provider regardless of provider user key type

This commit is contained in:
Shannon
2014-04-24 12:12:06 +10:00
parent 2c1807bb37
commit e10e04aabf
2 changed files with 15 additions and 4 deletions

View File

@@ -65,7 +65,9 @@ namespace Umbraco.Core.Security
public static MembershipUser GetCurrentUser(this MembershipProvider membershipProvider)
{
var username = membershipProvider.GetCurrentUserName();
return membershipProvider.GetUser(username, true);
return username.IsNullOrWhiteSpace()
? null
: membershipProvider.GetUser(username, true);
}
/// <summary>
@@ -78,7 +80,7 @@ namespace Umbraco.Core.Security
if (HostingEnvironment.IsHosted)
{
HttpContext current = HttpContext.Current;
if (current != null)
if (current != null && current.User != null && current.User.Identity != null)
return current.User.Identity.Name;
}
IPrincipal currentPrincipal = Thread.CurrentPrincipal;