Wednesday, October 13, 2010

Modx 2 showing error page instead of unauthorize page

In modx 1, its a direct method to setup article / post permission.
1st, setting up resource group. Then setup user group, and add in resource group to user group.
Next, assign user to user group.
Finally, when someone not logged in, the user will be shown a unauthorized page.

But in modx2, there are extra steps to setup this.
Notice that modx2 now have "minimum role", "access policy", "context".
1st. setting up resource group. Then setup user group. Right click on user group, and click "Update user group".
Click on "Resource Group Access" tab, "add resource group"
Select the resource group you created.
Minimum Role: Member (9999)
Access policy: "Load, list and view"
Context: Web

This allow user of type member to load the document, or list it out in rss and also view the document.

Now that you have protected this page, you will notice the unauthorised user will see a error page when trying to view this page. By right, the guest should see the unauthorized page instead...

Okay, to fix this, Go to "Access Control",
Right click on "(Anonymous)", and click "Update user group".
Click on "Resource Group Access" tab, "add resource group".
Select the resource group you created.
Minimum Role: Member (9999)
Access policy: "Load"
Context: Web

This will allow guest to load the document, but will not allow guest to list or view the document. This is how modx2 policy works.

Hope it helps ;)

No comments: