[Zope] Getting a specific user role
Stuart 'Zen' Bishop
zen@cs.rmit.edu.au
Fri, 9 Jun 2000 13:16:56 +1000 (EST)
On Thu, 8 Jun 2000, Mabe, Brad wrote:
> Forgive me if this has been covered before.
>
> I am implementing a login/security scheme through the use of GUF and SQL
> methods. My user and role information is kept in a SQL database and a user
> can have more than one role assigned to him/her.
>
> What I would like to do is check if a specific role has been assigned to the
> current user, and then display some additional menu items if that role has
> been assigned. I haven't been able to figure out how to get and check the
> roles that have been assigned to the current user.
>
> As usual, any help will be greatly appreciated.
(untested)
<dtml-if "'myrole' in AUTHENTICATED_USER.getRolesInContext(this())">
User has the myrole role
</dtml-if>
getRoles is also there if you don't want to check for local roles.
--
Stuart Bishop Work: zen@cs.rmit.edu.au
Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au
Computer Science, RMIT University