If you are using Auth you may want to be able to impersonate a
different user without logout and without resetting all your session
variables.

This is how you can do it

#optonal: @auth.requires_permission
('impersonate',auth.table_user,request.args[0] if request.args else 0)
def impersonate():
    """ usage http://..../impersonate/[id] """
    auth.original_user = auth.user
    auth.user = auth.table_user._filter_fields(auth.table_user
[request.args[0]],True)
    return dict()

def un_impersonate():
    if auth.original_user:
        auth.user = auth.original_user
        auth.original_user = None
    return dict()

You can already do this. Should we make it easier and make them
methods of the Auth class?

Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to