[xwiki-users] rights of current user
I would like to have a script that finds out for which spaces the current user has view rights. I try to do: #set($spaces = $xwiki.spaces) #foreach($space in $spaces) #set($whome = $xwiki.getDocument("${space}.WebHome")) [$space>${space}.WebHome] #if($whome.hasAccessLevel("view",$xwiki.getUser())) acess? Yup<br> #else access? Nope<br> #end #end but hasAccessLevel always return false. What am I missing? Is there any other way to do this?
Hi, i think the problem is, that space preferences is in ${space}.WebPreferences page and not in WebHome. Your script just find, if the user have rights to WebHome page not for entire space. WebPreferences has object global rights and i think there you have to do some sql query to find out, if user have rights or not. Jan On 12/17/07, Bjørnar Libæk <[email protected]> wrote:
I would like to have a script that finds out for which spaces the current user has view rights. I try to do:
#set($spaces = $xwiki.spaces) #foreach($space in $spaces) #set($whome = $xwiki.getDocument("${space}.WebHome")) [$space>${space}.WebHome] #if($whome.hasAccessLevel("view",$xwiki.getUser())) acess? Yup<br> #else access? Nope<br> #end #end
but hasAccessLevel always return false. What am I missing? Is there any other way to do this?
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Bjørnar Libæk wrote:
I would like to have a script that finds out for which spaces the current user has view rights. I try to do:
#set($spaces = $xwiki.spaces) #foreach($space in $spaces) #set($whome = $xwiki.getDocument("${space}.WebHome")) [$space>${space}.WebHome]
#if($whome.hasAccessLevel("view",$context.getUser()))
#if($whome.hasAccessLevel("view",$xwiki.getUser())) acess? Yup<br> #else access? Nope<br> #end #end
but hasAccessLevel always return false. What am I missing? Is there any other way to do this?
------------------------------------------------------------------------
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Ok, maybe checking permission to WebHome isn't the best way to go, so if anyone could follow up on the "sql query" suggestion, it would be nice. However, I still don't understand why my script doesn't work. If a user has viewing rights on a WebHome page (the user can actually view the page), the hasAccessLevel method still returns false. Why is this?? I've tried replacing 'WebHome' with 'WebPreferences', but with the same result. Bjørnar Jan Kodera wrote:
Hi, i think the problem is, that space preferences is in ${space}.WebPreferences page and not in WebHome. Your script just find, if the user have rights to WebHome page not for entire space. WebPreferences has object global rights and i think there you have to do some sql query to find out, if user have rights or not.
Jan
On 12/17/07, *Bjørnar Libæk* <[email protected] <mailto:[email protected]>> wrote:
I would like to have a script that finds out for which spaces the current user has view rights. I try to do:
#set($spaces = $xwiki.spaces) #foreach($space in $spaces) #set($whome = $xwiki.getDocument("${space}.WebHome")) [$space>${space}.WebHome] #if($whome.hasAccessLevel("view",$xwiki.getUser())) acess? Yup<br> #else access? Nope<br> #end #end
but hasAccessLevel always return false. What am I missing? Is there any other way to do this?
_______________________________________________ users mailing list [email protected] <mailto:[email protected]> http://lists.xwiki.org/mailman/listinfo/users
------------------------------------------------------------------------
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
I try to use groups to determine my rights wherever possible, so for me I just do a check on the user's group membership. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Bjørnar Libæk Sent: 18 December 2007 09:32 To: XWiki Users Subject: Re: [xwiki-users] rights of current user Ok, maybe checking permission to WebHome isn't the best way to go, so if anyone could follow up on the "sql query" suggestion, it would be nice. However, I still don't understand why my script doesn't work. If a user has viewing rights on a WebHome page (the user can actually view the page), the hasAccessLevel method still returns false. Why is this?? I've tried replacing 'WebHome' with 'WebPreferences', but with the same result. Bjørnar Jan Kodera wrote:
Hi, i think the problem is, that space preferences is in ${space}.WebPreferences page and not in WebHome. Your script just find, if the user have rights to WebHome page not for entire space. WebPreferences has object global rights and i think there you have to do some sql query to find out, if user have rights or not.
Jan
On 12/17/07, *Bjørnar Libæk* <[email protected] <mailto:[email protected]>> wrote:
I would like to have a script that finds out for which spaces the current user has view rights. I try to do:
#set($spaces = $xwiki.spaces) #foreach($space in $spaces) #set($whome = $xwiki.getDocument("${space}.WebHome")) [$space>${space}.WebHome] #if($whome.hasAccessLevel("view",$xwiki.getUser())) acess? Yup<br> #else access? Nope<br> #end #end
but hasAccessLevel always return false. What am I missing? Is there any other way to do this?
_______________________________________________ users mailing list [email protected] <mailto:[email protected]> http://lists.xwiki.org/mailman/listinfo/users
---------------------------------------------------------------------- --
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Bjørnar Libæk wrote:
Sergiu Dumitriu wrote:
#if($whome.hasAccessLevel("view",$context.getUser()))
Ok, I tried this, but now the method returns true every time... Even when explicitly adding an access rule denying view access for a specific user, the method returns true.
This is the right method, check if you really can't view that page. Sergiu
Ok, this seems to work: #if($xwiki.hasAccessLevel("view",$context.getUser(),"${space}.WebHome")) The complete script is then: #set($spaces = $xwiki.spaces) #foreach($space in $spaces) [$space>${space}.WebHome] #if($xwiki.hasAccessLevel("view",$context.getUser(),"${space}.WebHome")) acess? Yup<br> #else access? Nope<br> #end #end
On 12/17/07, *Bjørnar Libæk* <[email protected] <mailto:[email protected]>> wrote: I would like to have a script that finds out for which spaces the current user has view rights. I try to do:
#set($spaces = $xwiki.spaces) #foreach($space in $spaces)
#set($whome = $xwiki.getDocument("${space}.WebHome")) [$space>${space}.WebHome] #if($whome.hasAccessLevel("view",$xwiki.getUser())) acess? Yup<br> #else access? Nope<br>
#end #end
but hasAccessLevel always return false. What am I missing? Is there any other way to do this?
On Dec 18, 2007 12:53 PM, Sergiu Dumitriu <[email protected]> wrote:
This is the right method, check if you really can't view that page.
I did check this. When trying to view the page, I got the "You are not allowed to view.." box, but the method returned true. As mentioned in my previous post, when using $xwiki.hasAccessLevel method I got the desired behaviour.
Bjørnar Libæk wrote:
On Dec 18, 2007 12:53 PM, Sergiu Dumitriu <[email protected]> wrote:
This is the right method, check if you really can't view that page.
I did check this. When trying to view the page, I got the "You are not allowed to view.." box, but the method returned true. As mentioned in my previous post, when using $xwiki.hasAccessLevel method I got the desired behaviour.
Then there's a bug somewhere...
On Dec 18, 2007 1:20 PM, Sergiu Dumitriu <[email protected]> wrote:
Then there's a bug somewhere...
Yes seems so. I should have mentioned that I use version 1.1-milestone-4. So this may have been fixed in newer versions.
participants (4)
-
Bjørnar Libæk -
Esbach, Brandon -
Jan Kodera -
Sergiu Dumitriu