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:14:06 +10:00
parent 437d1b759b
commit c32cae16db
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;

View File

@@ -228,8 +228,17 @@ namespace umbraco
if (CacheByPersonalization)
{
int currentMember = Member.CurrentMemberId();
id.AppendFormat("m{0}-", currentMember);
object memberId = 0;
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
var provider = Umbraco.Core.Security.MembershipProviderExtensions.GetMembersMembershipProvider();
var member = Umbraco.Core.Security.MembershipProviderExtensions.GetCurrentUser(provider);
if (member != null)
{
memberId = member.ProviderUserKey ?? 0;
}
}
id.AppendFormat("m{0}-", memberId);
}
foreach (var prop in model.Properties)