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

(-)a/C4/Auth.pm (+1 lines)
Lines 1021-1026 sub checkauth { Link Here
1021
1021
1022
            # $return: 1 = valid user, 2 = superlibrarian
1022
            # $return: 1 = valid user, 2 = superlibrarian
1023
            if ($return) {
1023
            if ($return) {
1024
                # If DB user is logged in
1024
                $userid ||= $q_userid if $return == 2;
1025
                $userid ||= $q_userid if $return == 2;
1025
1026
1026
                #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
1027
                #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
(-)a/t/db_dependent/Auth.t (-2 / +15 lines)
Lines 33-39 $schema->storage->txn_begin; Link Here
33
33
34
subtest 'checkauth() tests' => sub {
34
subtest 'checkauth() tests' => sub {
35
35
36
    plan tests => 1;
36
    plan tests => 2;
37
37
38
    my $patron = $builder->build({ source => 'Borrower', value => { flags => undef } })->{userid};
38
    my $patron = $builder->build({ source => 'Borrower', value => { flags => undef } })->{userid};
39
39
Lines 47-52 subtest 'checkauth() tests' => sub { Link Here
47
47
48
    is( $userid, undef, 'checkauth() returns undef for userid if no logged in user (Bug 18275)' );
48
    is( $userid, undef, 'checkauth() returns undef for userid if no logged in user (Bug 18275)' );
49
49
50
    my $db_user_id = C4::Context->config('user');
51
    my $db_user_pass = C4::Context->config('pass');
52
    $cgi = Test::MockObject->new();
53
    $cgi->mock( 'cookie', sub { return; } );
54
    $cgi->mock( 'param', sub {
55
            my ( $self, $param ) = @_;
56
            if ( $param eq 'userid' ) { return $db_user_id; }
57
            elsif ( $param eq 'password' ) { return $db_user_pass; }
58
            else { return; }
59
        });
60
    ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, $authnotrequired );
61
    is ( $userid, $db_user_id, 'If DB user is logging in, it should be considered as logged in, i.e. checkauth return the relevant userid' );
62
    C4::Context->_new_userenv; # For next tests
63
50
};
64
};
51
65
52
my $hash1 = hash_password('password');
66
my $hash1 = hash_password('password');
53
- 

Return to bug 18442