Skip to content

Commit a768fe5

Browse files
Ports behaviour from membershiphelper from v7 to 6 to make them the same
1 parent d9c66cd commit a768fe5

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/Umbraco.Web/Security/MembershipHelper.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,15 @@ public ProfileModel GetCurrentMemberProfileModel()
276276
{
277277
var membershipUser = provider.GetCurrentUser();
278278
var member = GetCurrentMember();
279-
//this shouldn't happen
280-
if (member == null) return null;
279+
//this shouldn't happen but will if the member is deleted in the back office while the member is trying
280+
// to use the front-end!
281+
if (member == null)
282+
{
283+
//log them out since they've been removed
284+
FormsAuthentication.SignOut();
285+
286+
return null;
287+
}
281288

282289
var model = ProfileModel.CreateModel();
283290
model.Name = member.Name;
@@ -416,17 +423,31 @@ public LoginStatusModel GetCurrentLoginStatus()
416423
if (provider.IsUmbracoMembershipProvider())
417424
{
418425
var member = GetCurrentMember();
419-
//this shouldn't happen
420-
if (member == null) return model;
426+
//this shouldn't happen but will if the member is deleted in the back office while the member is trying
427+
// to use the front-end!
428+
if (member == null)
429+
{
430+
//log them out since they've been removed
431+
FormsAuthentication.SignOut();
432+
model.IsLoggedIn = false;
433+
return model;
434+
}
421435
model.Name = member.Name;
422436
model.Username = member.Username;
423437
model.Email = member.Email;
424438
}
425439
else
426440
{
427441
var member = provider.GetCurrentUser();
428-
//this shouldn't happen
429-
if (member == null) return null;
442+
//this shouldn't happen but will if the member is deleted in the back office while the member is trying
443+
// to use the front-end!
444+
if (member == null)
445+
{
446+
//log them out since they've been removed
447+
FormsAuthentication.SignOut();
448+
model.IsLoggedIn = false;
449+
return model;
450+
}
430451
model.Name = member.UserName;
431452
model.Username = member.UserName;
432453
model.Email = member.Email;

0 commit comments

Comments
 (0)