From: Tomas Doran Date: Thu, 19 Aug 2010 18:02:48 +0000 (+0000) Subject: I think this actually works X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Forigin%2Ffix_connect_as_user_with_session;p=catagits%2FCatalyst-Authentication-Store-LDAP.git I think this actually works --- diff --git a/lib/Catalyst/Authentication/Store/LDAP/Backend.pm b/lib/Catalyst/Authentication/Store/LDAP/Backend.pm index c601e59..6ba93bd 100644 --- a/lib/Catalyst/Authentication/Store/LDAP/Backend.pm +++ b/lib/Catalyst/Authentication/Store/LDAP/Backend.pm @@ -71,6 +71,7 @@ use base qw( Class::Accessor::Fast ); use strict; use warnings; +use Scalar::Util qw/refaddr/; our $VERSION = '1.011'; @@ -438,12 +439,11 @@ Returns get_user() for I. sub from_session { my ( $self, $c, $id ) = @_; my $pass; - if ($id =~ s/,(.*)//) { - my $pass = $1; - } + ($id, $pass) = split /,/, $id; my $user = $self->get_user($id, $c); if ($pass) { $Catalyst::Authentication::Store::LDAP::User::_ldap_connection_passwords{refaddr($user)} = $pass; + warn("SET PASS FOR RESTORED USER TO $pass"); } return $user; } diff --git a/lib/Catalyst/Authentication/Store/LDAP/User.pm b/lib/Catalyst/Authentication/Store/LDAP/User.pm index 5a21827..aa4300d 100644 --- a/lib/Catalyst/Authentication/Store/LDAP/User.pm +++ b/lib/Catalyst/Authentication/Store/LDAP/User.pm @@ -251,8 +251,13 @@ as, and returns a L object which you can use to do further queries. sub ldap_connection { my $self = shift; + my $password = $_ldap_connection_passwords{refaddr($self)}; + unless ($password) { + warn("No password stored with user, cannot restore from session"); + return; + } $self->store->ldap_bind( undef, $self->ldap_entry->dn, - $_ldap_connection_passwords{refaddr($self)} ); + $password ); } =head2 AUTOLOADed methods