On 14 sep, 14:24, mdipierro <[email protected]> wrote:
> you can do
>
> @auth.requires(auth.has_membership(auth.id_group('role1')) or
> auth.has_membership(auth.id_group('role2')))
>
> but this is not the right way to handle it.
>
> You should add permissions:
>
> auth.add_permission('run_this',group_id=id.group('role1'))
> auth.add_permission('run_this',group_id=id.group('role2'))
>
> and then check if user is a member of a group that has such
> permissions
>
> @auth.requires_permission('run_this')
>
Massimo,
There's something wrong that does not work.
I have in auth_user:
id_user=1; user=user1
id_user=2; user=user2
the login works fine.
also, in auth_group:
id_group=1; role=role1
id_group=2; role=role2
in auth_membership:
id_user=1; id_group=1
id_user=2; id_group=2
in auth_permission:
id_group=1; name=a_name
id_group=2; name=other_name
in controller:
@auth.requires_permission('a_name)
def my_function1():
return dict()
@auth.requires_permission('other_name)
def my_function2():
return dict()
I hope: user1 can run my_function1 and user2 can run my_function2, but
always get a Insufficient privileges
Regards,
Jose
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---