On Monday, October 24, 2011 5:29:41 PM UTC-4, lucas wrote:
>
> ok, that was totally helpful, thanx for all of the help.
>
> i have gotten far, using has_membership and requires_membership often
> and working perfectly, both in controllers and views.
>
> having a bit of a problem with auth.has_permission(). i have a group/
> role, auth_group id=2, called Guest and under auth_permission, id=2
> also, with group_id=2 with name="News Restricted". table_name is Null
> and record_id=0. i also have an entry under auth_user with id=2,
> email '[email protected]' just for fun, and an entry under
> auth_membership, id=4, with user_id=2 and group_id=2. so all that
> means is that user [email protected] should be a Guest with permission
> set to true for "News Restricted". ok?
>
> how come when [email protected] is logged in, auth.has_permission('News
> Restricted') proves False. Shouldn't it be True?
>
>From your description, sounds like it should be True. Maybe try specifying
an "object" in the permission as well -- e.g.,
auth.add_permission(group_id=2, name="read", table_name="news"). Note,
table_name doesn't have to be an actual table -- it can be any arbitrary
concept. For example, if you have a function that returns some news, you
could decorate it with @auth.requires_permission('read', 'news').
Anthony