https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36503

--- Comment #17 from Michaela Sieber <michaela.sie...@kit.edu> ---
(In reply to David Cook from comment #16)
> (In reply to Raphael Straub from comment #13)
> > In our use case having access to the domain is not necessary, but calling
> > the hook before $patron->…->store with the domain as an additional argument
> > could be a good idea. Then the plugin might modify $domain->update_on_auth,
> > $domain->default_category_id or $domain->default_library_id.
> 
> The more I look at Koha::Auth::Client, the more I think the already existing
> approach has its flaws (like arbitrarily setting the branchcode and
> categorycode in the $mapped_data at the end of get_user()... I think that's
> probably a bug in the current implementation).
> 
> --
> 
> Could you describe your use case more?
> 
> I know someone who might be interested in this as well, so I'd like to get
> more feedback...


Hi David, 

our use case is described in the Description of this bug. We use this hook to
match and afterwards to update the patron record via data we get from the
identity provider after the patron has authenticated. All this is done behind
the scenes, the patron does not recognize this process, he just uses the normal
authentication process he is used to (in the university context)
We do not change the branchcode or the categorycode.

This is our code :

sub auth_client_get_user {
    my ( $self, $args ) = @_;

    my $logger = Koha::Logger->get();
    my $mapped_data = $args->{'mapped_data'};
    if ( !$args->{'patron'} ) {
        $logger->warn('Patron not found, find patron by card number');
        $logger->warn(encode_json($mapped_data));
    }

    if ( defined $mapped_data->{'cardnumber'} ) {
        # Split data (e. g. kit.edu:123456789) and set the card number.
        my ( $card_domain, $cardnumber ) = split( /\:/,
$mapped_data->{'cardnumber'} );
        $mapped_data->{'cardnumber'} = $cardnumber;
        $logger->warn( 'cardnumber: ' . $cardnumber );

        if ( !$args->{'patron'} ) {
            # Find the patron by card number.
            my $patrons = Koha::Patrons->search( { 'cardnumber' => $cardnumber
} );
            if ( $patrons->count == 1 ) {
                $args->{'patron'} = $patrons->next;
                $logger->warn('Patron found.');
            }
        }
    }

    return;
}




If you see problems in Koha::Auth::Client this should be filed in a separate
bug.
We think this new hook has no negative effects on existing koha community code.

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
Koha-bugs@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to