U4-4530 - Edit Profile Snippet: Check for null before loop

Created by Bjarne Fyrstenborg 26 Mar 2014, 14:21:01 Updated by Shannon Deminick 27 Mar 2014, 05:51:16

I noticed in the edit profile partial view snippet, when you are logged in as a member and if you in Umbraco delete the member that is logged in - then on the page where you use the partial view editProfile.cshtml you will get an "Object reference not set to an instance of an object." error message.

So if you check for null, you will not recieve this error:

@if(profileModel != null) { for (var i = 0; i < profileModel.MemberProperties.Count; i++) { @Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name) @* By default this will render a textbox but if you want to change the editor template for this property you can easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to render your specific editor template like: @Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor") *@ @Html.EditorFor(m => profileModel.MemberProperties[i].Value) @Html.HiddenFor(m => profileModel.MemberProperties[i].Alias)
} }

However I am not sure if Umbraco also should logout the user when the member in case the member is deleted?

Comments

Shannon Deminick 27 Mar 2014, 05:44:50

Thanks, i'll update the method: Members.GetCurrentMemberProfileModel();

to check for a null value on return and if they are logged in they'll be logged out and update the snippet.


Shannon Deminick 27 Mar 2014, 05:51:13

done in rev 264c537b50a881c12c8ae56f3c3c548b1c2ab9f1


Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.1.0

Due in version: 7.1.0

Sprint:

Story Points:

Cycle: