[Catalyst] Re: superuser "switch-user" session function?

Peter Karman peter at peknet.com
Tue Nov 30 15:01:05 GMT 2010


will trillich wrote on 11/29/2010 05:37 PM:
> Aha! It looks like a sneaky, evil, wrong, mean, horrid way to
> switch-user in the middle of a session is to
> 
> $c->session->{__user}{id} = $new_id_here; # since "id" = PK
> 
> But that's undoubtedly bad form of the worst kind.
> 
> What's the canonical non-sneaky above-board friendly golden way to do this?
> 

I don't know that there is a canonical way. This is Perl.

As I mentioned in my reply to this thread in July[0], one way is to
login as the new user and store the original username in the new user's
session. That way the app knows that the new user is allowed to revert
to the original user, but otherwise the app treats the current session
just as it would if the new user had logged in normally.


[0] http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg09968.html

-- 
Peter Karman  .  http://peknet.com/  .  peter at peknet.com



More information about the Catalyst mailing list