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

Denny 2010 at denny.me
Tue Nov 30 00:19:28 GMT 2010


On Mon, 2010-11-29 at 17:37 -0600, will trillich wrote:
> 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?

t0m wrote something on the list a while back about putting your user
details into the stash manually rather than using $c->user directly.
One of the reasons he gave was that then, if you want to override the
(perceived) user session, you can override $c->stash->{ user } instead
of having to mess with $c->user itself.

Although presumably it would make sense to hinge the admin-only
functions (such as 'switch user') off of $c->user - so that you can
still switch back when you're done  :)

Regards,
Denny





More information about the Catalyst mailing list