X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FStore%2FDBIx%2FClass%2FUser.pm;h=18282a4ab35429aad42251707dab1d4e4022873b;hb=c30ad9df2c49e9f51435b03182a2bf263c69d63e;hp=dddcdaaa4c13880bddcd454903527fb5ea19f954;hpb=e746d3632ac74508361a0745f333f431aa7b5fc2;p=catagits%2FCatalyst-Authentication-Store-DBIx-Class.git diff --git a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm index dddcdaa..18282a4 100644 --- a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm +++ b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm @@ -72,7 +72,7 @@ sub load { } ## User can provide an arrayref containing the arguments to search on the user class. - ## or even provide a prepared resultset, allowing maximum flexibility for user retreival. + ## or even provide a prepared resultset, allowing maximum flexibility for user retrieval. ## these options are only available when using the dbix_class authinfo hash. if ($dbix_class_config && exists($authinfo->{'result'})) { $self->_user($authinfo->{'result'}); @@ -189,7 +189,17 @@ sub from_session { # ## 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 }); + + # We need to use inflate_result here since we -are- inflating a + # result object from cached data, not creating a fresh one. + # Components such as EncodedColumn wrap new() to ensure that a + # provided password is hashed on the way in, and re-running the + # hash function on data being restored is expensive and incorrect. + + my $class = $self->resultset->result_class; + my $source = $self->resultset->result_source; + my $obj = $class->inflate_result($source, { %$frozenuser }); + $obj->in_storage(1); $self->_user($obj); return $self; @@ -251,7 +261,11 @@ sub can { my $self = shift; return $self->SUPER::can(@_) || do { my ($method) = @_; - if (my $code = $self->_user->can($method)) { + if (not ref $self) { + undef; + } elsif (not $self->_user) { + undef; + } elsif (my $code = $self->_user->can($method)) { sub { shift->_user->$code(@_) } } elsif (my $accessor = try { $self->_user->result_source->column_info($method)->{accessor} }) { @@ -267,6 +281,8 @@ sub AUTOLOAD { (my $method) = (our $AUTOLOAD =~ /([^:]+)$/); return if $method eq "DESTROY"; + return unless ref $self; + if (my $code = $self->_user->can($method)) { return $self->_user->$code(@_); } @@ -292,7 +308,7 @@ module. =head1 VERSION -This documentation refers to version 0.1500. +This documentation refers to version 0.1503. =head1 SYNOPSIS @@ -372,11 +388,11 @@ that method (probably in your schema file) =head2 AUTOLOAD -Delegates method calls to the underlieing user row. +Delegates method calls to the underlying user row. =head2 can -Delegates handling of the C<< can >> method to the underlieing user row. +Delegates handling of the C<< can >> method to the underlying user row. =head1 BUGS AND LIMITATIONS