Manually process Permissions.cs

Topics: Writing modules
May 16, 2015 at 12:42 AM
I have a bit of a chicken before the egg situation here...

I have a custom module that when enabled, runs code that creates a custom Role. This module also has a Permissions.cs file that assigns a permission to the custom Role that is created when the module is enabled.

The issue is that the permission is never being assigned to the role. My guess is that is happening because Orchard is processing the Permissions.cs file when the module is enabled and that is happening before the custom Role is being created. there a way to force the re-processing of the Permissions.cs file so that the permission is assigned to the Role? Or am I better off explicitly adding those permissions to the Role when I create it?

Thanks =)
May 16, 2015 at 12:26 PM
Can you not give that role the permission explicitly in the default stereotypes? So...
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
            return new[] {
                new PermissionStereotype {
                    Name = "YourCustomRole",
                    Permissions = new[] {ThePermission}