Custom Module Permissions

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
5/3/2010 11:25:27 AM
Gravatar
Total Posts 0

Custom Module Permissions

Does anyone know how to create a custom module permission?  I don't want to give users edit permissions to my custom modules, but do need to be able to assign elevated permissions to certain roles.  For example, consider a time management module.  I want users to only be able to view (maybe edit) their own and anyone in the "Managers" role should be able to view/edit all employee's records.  I don't want the Managers to be able to modify module settings so need to create a new permissions for this module called something like "Can Edit Entries" and be able to assign that permission to roles and possibly individual users.  I have read through the development docs and haven't been able to find anything that explains how to do this.  Any help is much appreciated.

Thanks,
Adam

5/3/2010 11:40:54 AM
Gravatar
Total Posts 18439

Re: Custom Module Permissions

 

Hi Adam,

You can define a module setting in a module definition file that allows selecting roles using a built in control.

<featureSetting
   resourceFile="YourResourceFile"
   resourceKey="RolesThatCanDoFoo"
   defaultValue=""
   controlType="ISettingControl"
      controlSrc="~/Controls/AllowedRolesSetting.ascx"
      helpKey=""
      sortOrder="350"
   regexValidationExpression=""
   />

You then can retrieve the value from Module Settings and check the current user with if(WebUser.IsInRoles(allowedRoles))

Note that this method will always resolve as true for users in the admins role whether you include that role or not

There is also a RoleNotAllowedToEditModuleSettings in site settings > Security > Permissions so you can prevent users from changing the allowed roles.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.