[xwiki-users] Menu Application access for Unregistered Users
I am in a private wiki site used for documentation. You must be a user to see anything, so "Unregistered Users" can only see the login page. On my wiki I am using the "Menu Application", which unregistered users do not have access to. So on the login page there is an error "Failed to execute the [include] macro". The long version says org.xwiki.rendering.macro.MacroExecutionException: Current user [XWiki.XWikiGuest] doesn't have view rights on document [xwiki:Menu.Wiki Level Menu] This is correct. I don't want XWikiGuest to see the menu. Any idea how I could get rid of the error? I tried searching and found references to xwiki.hasAccessLevel. Am I on the right track? I am using XWiki 5.4.2 with MySQL and Tomcat 7 -- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-access-for-Unregistered-U... Sent from the XWiki- Users mailing list archive at Nabble.com.
I fixed it by modifying the code in Menu.MenuMacro. I wrapped it in an if($isGuest) like this. {{velocity}} #if ($isGuest) #else #set ($id = $xcontext.macro.params.id) #set ($type = $xcontext.macro.params.type) #set ($colorTheme = $xwiki.getUserPreference('colorTheme')) #if ("$!colorTheme" != '') ## Make sure we use an absolute reference (see XWIKI-9672) #set ($colorTheme = $services.model.resolveDocument($colorTheme, $doc.documentReference)) #end #set ($discard = $xwiki.ssx.use("$xcontext.macro.doc.prefixedFullName", {'colorTheme': $colorTheme})) #set ($discard = $xwiki.jsx.use("$xcontext.macro.doc.prefixedFullName")) (% #if ("$!id" != '') id="$id"#end class="menu menu-$!type" %)((( $xcontext.macro.content ))) #end {{/velocity}} Sorry, I don't know the scripting language well enough to do a ($isGuest) == false. -- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-access-for-Unregistered-U... Sent from the XWiki- Users mailing list archive at Nabble.com.
I fixed this by modifying the Menu.MenuMacro in Object mode and then changing the code in the XWiki.WikiMacroClass. I added a condition that looked to see if the user was a guest. What I added is in bold below. {{velocity}} #set ($id = $xcontext.macro.params.id) #set ($type = $xcontext.macro.params.type) #set ($colorTheme = $xwiki.getUserPreference('colorTheme')) #if ("$!colorTheme" != '') ## Make sure we use an absolute reference (see XWIKI-9672) #set ($colorTheme = $services.model.resolveDocument($colorTheme, $doc.documentReference)) #end #set ($discard = $xwiki.ssx.use("$xcontext.macro.doc.prefixedFullName", {'colorTheme': $colorTheme})) #set ($discard = $xwiki.jsx.use("$xcontext.macro.doc.prefixedFullName")) (% #if ("$!id" != '') id="$id"#end class="menu menu-$!type" %)(((*#if ($isGuest == false)* $xcontext.macro.content *#end*))) {{/velocity}} -- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-access-for-Unregistered-U... Sent from the XWiki- Users mailing list archive at Nabble.com.
Thanks for sharing DeHaynes, we were having the same issue! -- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-access-for-Unregistered-U... Sent from the XWiki- Users mailing list archive at Nabble.com.
On 02/28/2014 07:11 PM, DeHaynes wrote:
I fixed it by modifying the code in Menu.MenuMacro. I wrapped it in an if($isGuest) like this.
{{velocity}} #if ($isGuest) #else #set ($id = $xcontext.macro.params.id) #set ($type = $xcontext.macro.params.type) #set ($colorTheme = $xwiki.getUserPreference('colorTheme')) #if ("$!colorTheme" != '') ## Make sure we use an absolute reference (see XWIKI-9672) #set ($colorTheme = $services.model.resolveDocument($colorTheme, $doc.documentReference)) #end #set ($discard = $xwiki.ssx.use("$xcontext.macro.doc.prefixedFullName", {'colorTheme': $colorTheme})) #set ($discard = $xwiki.jsx.use("$xcontext.macro.doc.prefixedFullName")) (% #if ("$!id" != '') id="$id"#end class="menu menu-$!type" %)((( $xcontext.macro.content ))) #end {{/velocity}}
Sorry, I don't know the scripting language well enough to do a ($isGuest) == false.
#if (!$isGuest) should do the trick :) A slightly better check might be to see if the current user (who ever this is) has view rights on the document to be included, via $xwiki.hasAccessLevel('view', $xcontext.userReference, <insert page ref here>) But this seems to be in a different place, (and I have to admit I do not know the menu extension good enough to know where it is).
Thank you. -- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-access-for-Unregistered-U... Sent from the XWiki- Users mailing list archive at Nabble.com.
See http://jira.xwiki.org/browse/XWIKI-10171 . Check the changes in the Commits tab. On Mon, Mar 3, 2014 at 3:42 PM, DeHaynes <[email protected]> wrote:
Thank you.
-- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-access-for-Unregistered-U... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (4)
-
Clemens Robbenhaar -
DeHaynes -
Hamster -
Marius Dumitru Florea