User permission check improvements

This PR fix a problem with the module_configure.html view, for which permission was `resource="admin.module"`. This is wrong, as the permission to check here is `module=the_module_code`.

The permission checking process is slightly improved, to redirect the user who do not have the require permissions to the "Sorry, you're not allowed to perform this action " error page instead of always redirecting to the login page.