Merge branches/no-unneeded-fields into trunk
Andrew Rodland [Fri, 17 Jun 2011 16:03:55 +0000 (16:03 +0000)]
Changes
lib/Catalyst/Authentication/Store/DBIx/Class/User.pm

diff --git a/Changes b/Changes
index 542c1f7..f5e81ac 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Catalyst-Plugin-Authentication-Store-DBIx-Class
 
+        * If use_userdata_from_session isn't set, then don't store more
+          fields than we need in the session -- only the fields we need to
+          load the object from the DB again.
+
 0.1500  2010-11-16
         * Allow specifying a fully loaded DBIC result in addition to resultsets
           of which only the first row is considered.
index 7a78a7b..dddcdaa 100644 (file)
@@ -165,7 +165,14 @@ sub for_session {
     #return $frozenuser;
 
     my %userdata = $self->_user->get_columns();
-    return \%userdata;
+
+    # If use_userdata_from_session is set, then store all of the columns of the user obj in the session
+    if (exists($self->config->{'use_userdata_from_session'}) && $self->config->{'use_userdata_from_session'} != 0) {
+        return \%userdata;
+    } else { # Otherwise, we just need the PKs for load() to use.
+        my %pk_fields = map { ($_ => $userdata{$_}) } @{ $self->config->{id_field} };
+        return \%pk_fields;
+    }
 }
 
 sub from_session {