Hi,
I agree that check should be inside the null check for moduleconfiguration like this, I will change it like this:
private bool ShouldAllowEdit()
{
if (WebUser.IsAdmin)
{
return true;
}
if (moduleConfiguration != null)
{
if (moduleConfiguration.AuthorizedEditRoles == "Admins;") { return false; }
if (currentPage.EditRoles == "Admins;") { return false; }
if (WebUser.IsContentAdmin) { return true; }
if (isSiteEditor) { return true; }
if (WebUser.IsInRoles(moduleConfiguration.AuthorizedEditRoles)) { return true; }
if((!moduleConfiguration.IsGlobal)&&WebUser.IsInRoles(currentPage.EditRoles)) { return true;}
}
return false;
}
However, the question is why is it null in your custom modules and not null in included features?
If it is null it is going to return false in any case, so you should figure out why it is null in your feature and try to make it not be null.
Hope that helps,
Joe