If I understand the concept, when you set a registration_key in auth_user table (any value), it don't allow the user to login.
If you want to restrict acess in a menu, I do the following, using auth_groups, auth_permission and auth_membership: (you have to create groups, assign permission to them, and them assign the user to a group) response.menu = [ (T('Index'), False, URL(request.application,'default','index'), []) ] if auth.has_permission('representante',''): response.menu+=[ (T('Conselho Municipal'), False, URL(request.application, 'conselho_municipal', 'index'), [ (T('Cadastro'), False, URL(request.application, 'conselho_municipal', 'cadastro')), (T('Nomeação'), False, URL(request.application, 'conselho_municipal', 'nomeacao')), (T('Posse'), False, URL(request.application, 'conselho_municipal', 'posse')), (T('Conselheiros'), False, URL(request.application, 'conselho_municipal', 'conselheiros')), (T('Atas'), False, URL(request.application, 'conselho_municipal', 'atas')), ] ), 2011/2/9 Richard Vézina <ml.richard.vez...@gmail.com> > Hello, > > I would create button to block or unblock user access, so I made those > function : > > def block_access(): > """ > UPDATE auth_user > SET registration_key='blocked' > WHERE auth_user.registration_key = '' > AND auth_user.email <> 'myem...@mydomain.com' > """ > db((db.auth_user.registration_key == '') & (db.auth_user.email != ' > myem...@mydomain.com')).update(registration_key='blocked') > db.commit() > > def unblock_access(): > """ > UPDATE auth_user > SET registration_key='' > WHERE auth_user.registration_key <> 'pending' > """ > db(db.auth_user.registration_key != > 'pending').update(registration_key='') > db.commit() > > Now I would call those function from a link or a button from index or admin > dashboard... > > I would know if there is a other way except this : > > def index(): > block_access=A(T('block access'),_href=URL(r=request,c='default', > f='block_access')) > unblock_access=A(T('unblock access'),_href=URL(r=request,c='default', > f='unblock_access')) > return dict(block_access=block_access, unblock_access=unblock_access) > > Since I will need to modify the block and unblock function like this : > > def block_access(): > """ > UPDATE auth_user > SET registration_key='blocked' > WHERE auth_user.registration_key = '' > AND auth_user.email <> 'myem...@mydomain.com' > """ > db((db.auth_user.registration_key == '') & (db.auth_user.email != ' > myem...@mydomain.com')).update(registration_key='blocked') > db.commit() > redirect(URL(r=request,c='default', f='index')) > > Is there an other way by not utilising redirection? > > Thanks > > Richard > -- Atenciosamente Alexandre Andrade Hipercenter.com Classificados Gratuitos