You can make a group "buyers" and they buy something 
auth.add_membership(role="buyers") then check permissions with
@auth.requires_membership("buyers") 
or explicitly 
if auth.has_membership(role="buyers"): ...


On Monday, 16 December 2013 21:38:08 UTC-6, Henry Nguyen wrote:
>
> Hello,
>
> Our product has features which can be enabled or disabled depending on 
> what the user has purchased. I would like to use the built-in Auth 
> permissions functionality to achieve this effect. However, I'm not sure of 
> what's the best way to proceed with its implementation. The two scenarios I 
> can come up with based on my understanding of Auth are as follows:
>
> 1) Assign the permission to the auth_group to which the user exclusively 
> belongs (i.e. the default auth_group that is created when the auth_user is 
> created). Permissions would have to be re-assigned to this specific 
> auth_group on every registration and on every purchase or cancellation of a 
> feature.
>
> 2) Assign the permission to a previously-created auth_group and merely add 
> or remove the auth_user from that group. In other words, for "feature1", 
> create an auth_group "feature1_group" with auth_permission "has_feature1" 
> and add the auth_user to the feature1_group if he/she has purchased that 
> feature.
>
> On the one hand, going with scenario 2 and creating auth_groups for the 
> specific features seems a little cleaner in code. On the other hand, it 
> seems a little more intuitive (and reads slightly better) to think of 
> assigning permissions to the individual auth_user's group, even though this 
> would cause many more entries in the auth_permissions table. Is there a 
> generally-accepted (web2py-ic) way in which to handle this?
>
> Thank you ahead of time for any help.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to