From: Yuval Kogman Date: Sun, 4 Dec 2005 12:01:28 +0000 (+0000) Subject: User::Hash prefers id/store based serialization if it's possible X-Git-Tag: v0.04~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=87ca1824ddcc9dd4f3b1cfde15c302685228a2fd;p=catagits%2FCatalyst-Plugin-Authentication.git User::Hash prefers id/store based serialization if it's possible --- diff --git a/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm b/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm index 540b4d7..d08e330 100644 --- a/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm +++ b/lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm @@ -36,6 +36,8 @@ sub get_user { return $user; } elsif ( ref $user eq "HASH" ) { + $user->{id} ||= $id; + $user->{store} ||= $self; return bless $user, "Catalyst::Plugin::Authentication::User::Hash"; } else { diff --git a/lib/Catalyst/Plugin/Authentication/User/Hash.pm b/lib/Catalyst/Plugin/Authentication/User/Hash.pm index 962e91a..fb18c0b 100644 --- a/lib/Catalyst/Plugin/Authentication/User/Hash.pm +++ b/lib/Catalyst/Plugin/Authentication/User/Hash.pm @@ -85,7 +85,7 @@ sub supports { sub for_session { my $self = shift; - return $self; # let's hope we're serialization happy + return $self->store && $self->id || $self; # if we have a store and an ID we serialize by ref, otherwise we serialize the whole user } sub from_session {