[Catalyst-commits] r7464 -
trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class
jayk at dev.catalyst.perl.org
jayk at dev.catalyst.perl.org
Sun Mar 2 23:03:21 GMT 2008
Author: jayk
Date: 2008-03-02 23:03:20 +0000 (Sun, 02 Mar 2008)
New Revision: 7464
Modified:
trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
Log:
Adding backwards compatibility for DBIC style session variables
Modified: trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
===================================================================
--- trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm 2008-02-28 16:40:29 UTC (rev 7463)
+++ trunk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm 2008-03-02 23:03:20 UTC (rev 7464)
@@ -137,6 +137,10 @@
my $self = shift;
#return $self->get($self->config->{'id_field'});
+
+ #my $frozenuser = $self->_user->result_source->schema->freeze( $self->_user );
+ #return $frozenuser;
+
my %userdata = $self->_user->get_columns();
return \%userdata;
}
@@ -144,14 +148,30 @@
sub from_session {
my ($self, $frozenuser, $c) = @_;
- ## if use_userdata_from_session is defined in the config, we fill in the user data from the session.
- if (exists($self->config->{'use_userdata_from_session'}) && $self->config->{'use_userdata_from_session'} != 0) {
+ #my $obj = $self->resultset->result_source->schema->thaw( $frozenuser );
+ #$self->_user($obj);
+
+ #if (!exists($self->config->{'use_userdata_from_session'}) || $self->config->{'use_userdata_from_session'} == 0) {
+# $self->_user->discard_changes();
+# }
+#
+# return $self;
+#
+## if use_userdata_from_session is defined in the config, we fill in the user data from the session.
+ if (exists($self->config->{'use_userdata_from_session'}) && $self->config->{'use_userdata_from_session'} != 0)
+ {
my $obj = $self->resultset->new_result({ %$frozenuser });
$obj->in_storage(1);
$self->_user($obj);
return $self;
} else {
- return $self->load( { $self->config->{'id_field'} => $frozenuser->{$self->config->{'id_field'}} }, $c);
+ my $id;
+ if (ref($frozenuser) eq 'HASH') {
+ $id = $frozenuser->{$self->config->{'id_field'}};
+ } else {
+ $id = $frozenuser;
+ }
+ return $self->load( { $self->config->{'id_field'} => $id }, $c);
}
}
More information about the Catalyst-commits
mailing list