From a768fe5bb3fb0fa623f8b644dee789fd6bb5695c Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 2 Apr 2014 11:42:48 +0200 Subject: [PATCH] Ports behaviour from membershiphelper from v7 to 6 to make them the same --- src/Umbraco.Web/Security/MembershipHelper.cs | 33 ++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Security/MembershipHelper.cs b/src/Umbraco.Web/Security/MembershipHelper.cs index 4572026938..d1db014436 100644 --- a/src/Umbraco.Web/Security/MembershipHelper.cs +++ b/src/Umbraco.Web/Security/MembershipHelper.cs @@ -276,8 +276,15 @@ namespace Umbraco.Web.Security { var membershipUser = provider.GetCurrentUser(); var member = GetCurrentMember(); - //this shouldn't happen - if (member == null) return null; + //this shouldn't happen but will if the member is deleted in the back office while the member is trying + // to use the front-end! + if (member == null) + { + //log them out since they've been removed + FormsAuthentication.SignOut(); + + return null; + } var model = ProfileModel.CreateModel(); model.Name = member.Name; @@ -416,8 +423,15 @@ namespace Umbraco.Web.Security if (provider.IsUmbracoMembershipProvider()) { var member = GetCurrentMember(); - //this shouldn't happen - if (member == null) return model; + //this shouldn't happen but will if the member is deleted in the back office while the member is trying + // to use the front-end! + if (member == null) + { + //log them out since they've been removed + FormsAuthentication.SignOut(); + model.IsLoggedIn = false; + return model; + } model.Name = member.Name; model.Username = member.Username; model.Email = member.Email; @@ -425,8 +439,15 @@ namespace Umbraco.Web.Security else { var member = provider.GetCurrentUser(); - //this shouldn't happen - if (member == null) return null; + //this shouldn't happen but will if the member is deleted in the back office while the member is trying + // to use the front-end! + if (member == null) + { + //log them out since they've been removed + FormsAuthentication.SignOut(); + model.IsLoggedIn = false; + return model; + } model.Name = member.UserName; model.Username = member.UserName; model.Email = member.Email;