This project is read-only.

Why would calling UpdateEditor with a UserPart cause user roles to be removed?

Topics: Writing modules
Oct 31, 2011 at 12:21 PM

I am performing this sequence of actions within a controller function

            var user = _contentManager
                        .Query<UserPart, UserPartRecord>()
                        .Where(u => u.Id == viewModel.UserId)

            dynamic ci = user.ContentItem;
            ci.NewsletterSignUpPart.NewsAlert = viewModel.NewsAlert;
            ci.NewsletterSignUpPart.ProductUpdate = viewModel.ProductUpdate;

            model = _contentManager.UpdateEditor(user, this); 

I have created my own NewsletterSignUpPart which is a part of a UserPart. The properties of this part are boolean values.

Calling UpdateEditor modifies the properties of the NewsletterSignUp part for the user, BUT also removes all User roles for the user and I don't know why it is doing this.

Can anyone shed any light on this?

Oct 31, 2011 at 1:11 PM

Seems like calling _contentManager.UpdateEditor() is totally inappropriate here, as all I want to do is update the NewsletterSignUpPart, and there is no need to call UpdateEditor to do this.

Calling UpdateEditor with a UserPart will eventually look for a model containing the UserRoles and it doesn't find that (UserRolesPartDriver), so it removes all the user roles. (Correct me if I am wrong).