User::Hash prefers id/store based serialization if it's possible
Yuval Kogman [Sun, 4 Dec 2005 12:01:28 +0000 (12:01 +0000)]
lib/Catalyst/Plugin/Authentication/Store/Minimal/Backend.pm
lib/Catalyst/Plugin/Authentication/User/Hash.pm

index 540b4d7..d08e330 100644 (file)
@@ -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 {
index 962e91a..fb18c0b 100644 (file)
@@ -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 {