Bug 22461: Filter ldap mapping before inserting patron's info
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 21 Mar 2019 17:05:49 +0000 (14:05 -0300)
committerroot <root@f1ebe1bec408>
Thu, 18 Apr 2019 09:55:34 +0000 (09:55 +0000)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Auth_with_ldap.pm

index 3e2ab5c..6def54d 100644 (file)
@@ -221,7 +221,14 @@ sub checkpw_ldap {
                return(1, $cardnumber, $local_userid);
         }
     } elsif ($config{replicate}) { # A2, C2
-        my $patron = Koha::Patron->new( \%borrower )->store;
+        my @columns = Koha::Patrons->columns;
+        my $patron = Koha::Patron->new(
+            map {
+                grep join( ' ', @columns ) =~ /$_/
+                  ? ( $_ => $data{$_} )
+                  : ()
+            } keys %borrower
+        )->store;
         die "Insert of new patron failed" unless $patron;
         $borrowernumber = $patron->borrowernumber;
         C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } );