Creating a Custom Part attached to UserPart (a la Skywalker)

Topics: Writing modules
Oct 8, 2012 at 5:17 PM


I am creating a module in which I have a custom content part called an "EcoUser" (for ecosystem user) that I define this way in Migrations.cs:

ContentDefinitionManager.AlterTypeDefinition("EcoUser", type => type .WithPart("EcoUserPart")


I am using the method that is described in the blog post at where a customer is associated with a user, but my intent in this case is to associate the user with a database record in another system that is used to authenticate mobile application users (in another ASP.NET MVC 4 WebApi services project hosted elsewhere).

When I create the part using the ContentManager, a user is indeed created, and that user can log in.  However, when I administer the user using the admin account, I cannot assign any rights to it.  In fact, the administrative editor only displays the Orchard.Users editor (for a "user") and my editor (for an "EcoUser").  The panel that allows assigning "Adminstrator" rights does not appear at all.

How do I create this part, properly attached, with the ability to assign additional rights?  Is there anything else I should be doing other than creating an "EcoUserPart" and  "UserPart" with all the necessary properties set and calling ContentManager.Create() on the "EcoUser" to have a fully capable user created?

Thanks for any help...



Oct 8, 2012 at 7:11 PM
Edited Oct 8, 2012 at 7:11 PM

You will need to reverse your logic and add the EcoUserPart to the existing User content type, like so:


ContentDefinitionManager.AlterTypeDefinition("User", type => type.WithPart("EcoUserPart"));


The EcoUserPart should handle the foreign key to your seperate system, and you can create new users with ContentManager.Create("User")

Hope this helps?