View | Details | Raw Unified | Return to bug 18821
Collapse All | Expand All

(-)a/C4/Auth.pm (-2 / +4 lines)
Lines 774-779 sub checkauth { Link Here
774
    my $casparam = $query->param('cas');
774
    my $casparam = $query->param('cas');
775
    my $q_userid = $query->param('userid') // '';
775
    my $q_userid = $query->param('userid') // '';
776
776
777
    my $session;
778
777
    # Basic authentication is incompatible with the use of Shibboleth,
779
    # Basic authentication is incompatible with the use of Shibboleth,
778
    # as Shibboleth may return REMOTE_USER as a Shibboleth attribute,
780
    # as Shibboleth may return REMOTE_USER as a Shibboleth attribute,
779
    # and it may not be the attribute we want to use to match the koha login.
781
    # and it may not be the attribute we want to use to match the koha login.
Lines 799-805 sub checkauth { Link Here
799
    }
801
    }
800
    elsif ( $sessionID = $query->cookie("CGISESSID") )
802
    elsif ( $sessionID = $query->cookie("CGISESSID") )
801
    {    # assignment, not comparison
803
    {    # assignment, not comparison
802
        my $session = get_session($sessionID);
804
        $session = get_session($sessionID);
803
        C4::Context->_new_userenv($sessionID);
805
        C4::Context->_new_userenv($sessionID);
804
        my ( $ip, $lasttime, $sessiontype );
806
        my ( $ip, $lasttime, $sessiontype );
805
        my $s_userid = '';
807
        my $s_userid = '';
Lines 1193-1199 sub checkauth { Link Here
1193
        if ( $userid ) {
1195
        if ( $userid ) {
1194
            # track_login also depends on pref TrackLastPatronActivity
1196
            # track_login also depends on pref TrackLastPatronActivity
1195
            my $patron = Koha::Patrons->find({ userid => $userid });
1197
            my $patron = Koha::Patrons->find({ userid => $userid });
1196
            $patron->track_login if $patron;
1198
            $patron->track_login( { session => $session } ) if $patron;
1197
        }
1199
        }
1198
1200
1199
        return ( $userid, $cookie, $sessionID, $flags );
1201
        return ( $userid, $cookie, $sessionID, $flags );
(-)a/Koha/Patron.pm (-3 / +9 lines)
Lines 404-412 sub has_overdues { Link Here
404
404
405
sub track_login {
405
sub track_login {
406
    my ( $self, $params ) = @_;
406
    my ( $self, $params ) = @_;
407
    return if
407
    my $session = $params->{session};
408
        !$params->{force} &&
408
409
        !C4::Context->preference('TrackLastPatronActivity');
409
    return unless C4::Context->preference('TrackLastPatronActivity') || $params->{force};
410
411
    if ( $session ) {
412
        return if $session->param('tracked_for_session') && !$params->{force};
413
        $session->param('tracked_for_session', 1);
414
    }
415
410
    $self->lastseen( dt_from_string() )->store;
416
    $self->lastseen( dt_from_string() )->store;
411
}
417
}
412
418
(-)a/t/db_dependent/Members.t (-3 / +18 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 60;
20
use Test::More tests => 62;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
use Test::Exception;
23
23
Lines 350-361 $patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' }); Link Here
350
is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' );
350
is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' );
351
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' });
351
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' });
352
is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' );
352
is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' );
353
354
355
# Test method last_seen / TrackLastPatronActivity
353
my $patron2 = $builder->build({ source => 'Borrower', value => { lastseen => undef } });
356
my $patron2 = $builder->build({ source => 'Borrower', value => { lastseen => undef } });
354
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' );
357
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' );
355
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login;
358
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login;
356
is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should not be changed' );
359
is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should not be changed' );
360
357
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 });
361
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 });
358
isnt( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should be changed now' );
362
my $last_seen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen;
363
isnt( $last_seen, undef, 'Lastseen should be changed now' );
364
365
# Last seen shouldn't be updated a second time for this session
366
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' );
367
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login();
368
is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, $last_seen, 'Lastseen should not be changed' );
369
370
# If it's forced, it should still be updated
371
sleep(1); # We need to wait a tiny bit to make sure the timestamp will be different
372
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 });
373
isnt( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, $last_seen, 'Lastseen should be changed if forced' );
374
359
375
360
# Regression tests for BZ13502
376
# Regression tests for BZ13502
361
## Remove all entries with userid='' (should be only 1 max)
377
## Remove all entries with userid='' (should be only 1 max)
362
- 

Return to bug 18821