I think this actually works origin/fix_connect_as_user_with_session
Tomas Doran [Thu, 19 Aug 2010 18:02:48 +0000 (18:02 +0000)]
lib/Catalyst/Authentication/Store/LDAP/Backend.pm
lib/Catalyst/Authentication/Store/LDAP/User.pm

index c601e59..6ba93bd 100644 (file)
@@ -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<id>.
 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;
 }
index 5a21827..aa4300d 100644 (file)
@@ -251,8 +251,13 @@ as, and returns a L<Net::LDAP> 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