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

(-)a/C4/Auth.pm (-32 / +45 lines)
Lines 1247-1266 sub checkauth { Link Here
1247
                        $is_sco_user = 1;
1247
                        $is_sco_user = 1;
1248
                    }
1248
                    }
1249
1249
1250
                    $session->param( 'number',       $borrowernumber );
1250
                    C4::Context->setup_session({
1251
                    $session->param( 'id',           $userid );
1251
                        session => $session,
1252
                    $session->param( 'cardnumber',   $cardnumber );
1252
                        data => {
1253
                    $session->param( 'firstname',    $firstname );
1253
                            'number',       $borrowernumber,
1254
                    $session->param( 'surname',      $surname );
1254
                            'id',           $userid,
1255
                    $session->param( 'branch',       $branchcode );
1255
                            'cardnumber',   $cardnumber,
1256
                    $session->param( 'branchname',   $branchname );
1256
                            'firstname',    $firstname,
1257
                            'surname',      $surname,
1258
                            'branch',       $branchcode,
1259
                            'branchname',   $branchname,
1260
                            'flags',        $userflags,
1261
                            'emailaddress', $emailaddress,
1262
                            'interface',    $type,
1263
                        },
1264
                    });
1265
1266
                    #NOTE: Additional session data needed for this authentication method
1257
                    $session->param( 'desk_id',      $desk_id);
1267
                    $session->param( 'desk_id',      $desk_id);
1258
                    $session->param( 'desk_name',     $desk_name);
1268
                    $session->param( 'desk_name',     $desk_name);
1259
                    $session->param( 'flags',        $userflags );
1260
                    $session->param( 'emailaddress', $emailaddress );
1261
                    $session->param( 'ip',           $session->remote_addr() );
1262
                    $session->param( 'lasttime',     time() );
1263
                    $session->param( 'interface',    $type);
1264
                    $session->param( 'shibboleth',   $shibSuccess );
1269
                    $session->param( 'shibboleth',   $shibSuccess );
1265
                    $session->param( 'register_id',  $register_id );
1270
                    $session->param( 'register_id',  $register_id );
1266
                    $session->param( 'register_name',  $register_name );
1271
                    $session->param( 'register_name',  $register_name );
Lines 1285-1294 sub checkauth { Link Here
1285
                    $info{'invalid_username_or_password'} = 1;
1290
                    $info{'invalid_username_or_password'} = 1;
1286
                    C4::Context::_unset_userenv($sessionID);
1291
                    C4::Context::_unset_userenv($sessionID);
1287
                }
1292
                }
1288
                $session->param( 'lasttime', time() );
1293
                C4::Context->setup_anon_session({
1289
                $session->param( 'ip',       $session->remote_addr() );
1294
                    session => $session,
1290
                $session->param( 'sessiontype', 'anon' );
1295
                    data => {
1291
                $session->param( 'interface', $type);
1296
                        interface => $type,
1297
                    },
1298
                });
1292
            }
1299
            }
1293
        }    # END if ( $q_userid
1300
        }    # END if ( $q_userid
1294
        elsif ( $type eq "opac" ) {
1301
        elsif ( $type eq "opac" ) {
Lines 1296-1305 sub checkauth { Link Here
1296
            # anonymous sessions are created only for the OPAC
1303
            # anonymous sessions are created only for the OPAC
1297
1304
1298
            # setting a couple of other session vars...
1305
            # setting a couple of other session vars...
1299
            $session->param( 'ip',          $session->remote_addr() );
1306
            C4::Context->setup_anon_session({
1300
            $session->param( 'lasttime',    time() );
1307
                session => $session,
1301
            $session->param( 'sessiontype', 'anon' );
1308
                data => {
1302
            $session->param( 'interface', $type);
1309
                    interface => $type,
1310
                },
1311
            });
1303
        }
1312
        }
1304
        $session->flush;
1313
        $session->flush;
1305
    }    # END unless ($userid)
1314
    }    # END unless ($userid)
Lines 1675-1692 sub check_api_auth { Link Here
1675
                        $branchname    = $branches->{$br}->{'branchname'};
1684
                        $branchname    = $branches->{$br}->{'branchname'};
1676
                    }
1685
                    }
1677
                }
1686
                }
1678
                $session->param( 'number',       $borrowernumber );
1687
1679
                $session->param( 'id',           $userid );
1688
                C4::Context->setup_session({
1680
                $session->param( 'cardnumber',   $cardnumber );
1689
                    session => $session,
1681
                $session->param( 'firstname',    $firstname );
1690
                    data => {
1682
                $session->param( 'surname',      $surname );
1691
                        'number',       $borrowernumber,
1683
                $session->param( 'branch',       $branchcode );
1692
                        'id',           $userid,
1684
                $session->param( 'branchname',   $branchname );
1693
                        'cardnumber',   $cardnumber,
1685
                $session->param( 'flags',        $userflags );
1694
                        'firstname',    $firstname,
1686
                $session->param( 'emailaddress', $emailaddress );
1695
                        'surname',      $surname,
1687
                $session->param( 'ip',           $session->remote_addr() );
1696
                        'branch',       $branchcode,
1688
                $session->param( 'lasttime',     time() );
1697
                        'branchname',   $branchname,
1689
                $session->param( 'interface',    'api'  );
1698
                        'flags',        $userflags,
1699
                        'emailaddress', $emailaddress,
1700
                        'interface',    'api',
1701
                    },
1702
                });
1690
            }
1703
            }
1691
            $session->param( 'cas_ticket', $cas_ticket);
1704
            $session->param( 'cas_ticket', $cas_ticket);
1692
            C4::Context->set_userenv(
1705
            C4::Context->set_userenv(
(-)a/C4/Context.pm (+53 lines)
Lines 1012-1017 sub is_internal_PSGI_request { Link Here
1012
    return $is_internal;
1012
    return $is_internal;
1013
}
1013
}
1014
1014
1015
=head3 setup_session
1016
1017
This function dictates what session parameters a Koha user session needs
1018
as a bare minimum.
1019
1020
=cut
1021
1022
sub setup_session {
1023
    my ($class,$args) = @_;
1024
    my $rv = 0;
1025
    my $session = $args->{'session'};
1026
    my $data = $args->{'data'};
1027
    if ( $session && $data ){
1028
        #NOTE: At some point, we might want to use data from a Koha::Patron object instead of many of these fields...
1029
        $session->param( 'number',       $data->{number} ); #borrowernumber
1030
        $session->param( 'id',           $data->{id} );
1031
        $session->param( 'cardnumber',   $data->{cardnumber} );
1032
        $session->param( 'firstname',    $data->{firstname} );
1033
        $session->param( 'surname',      $data->{surname} );
1034
        $session->param( 'branch',       $data->{branch} ); #branchcode
1035
        $session->param( 'branchname',   $data->{branchname} );
1036
        $session->param( 'flags',        $data->{flags} ); #userflags
1037
        $session->param( 'emailaddress', $data->{emailaddress} );
1038
        $session->param( 'ip',           $session->remote_addr() );
1039
        $session->param( 'lasttime',     time() );
1040
        $session->param( 'interface',    $data->{interface}  );
1041
        $rv = 1;
1042
    }
1043
    return $rv;
1044
}
1045
1046
=head3 setup_anon_session
1047
1048
This function dictates what session parameters an anonymous session needs
1049
as a bare minimum.
1050
1051
=cut
1052
1053
sub setup_anon_session {
1054
    my ($class,$args) = @_;
1055
    my $rv = 0;
1056
    my $session = $args->{session};
1057
    my $data = $args->{data};
1058
    if ( $session && $data ){
1059
        $session->param( 'ip',       $session->remote_addr() );
1060
        $session->param( 'lasttime', time() );
1061
        $session->param( 'interface', $data->{interface});
1062
        $session->param( 'sessiontype', 'anon' );
1063
        $rv = 1;
1064
    }
1065
    return $rv;
1066
}
1067
1015
__END__
1068
__END__
1016
1069
1017
=head1 ENVIRONMENT
1070
=head1 ENVIRONMENT
(-)a/C4/InstallAuth.pm (-13 / +17 lines)
Lines 317-335 sub checkauth { Link Here
317
                    "NO_LIBRARY_SET",            1,
317
                    "NO_LIBRARY_SET",            1,
318
                    ""
318
                    ""
319
                );
319
                );
320
                $session->param( 'number',     0 );
320
321
                $session->param( 'id',         C4::Context->config('user') );
322
                $session->param( 'cardnumber', C4::Context->config('user') );
323
                $session->param( 'firstname',  C4::Context->config('user') );
324
                $session->param( 'surname',    C4::Context->config('user'), );
325
                $session->param( 'branch',     'NO_LIBRARY_SET' );
326
                $session->param( 'branchname', 'NO_LIBRARY_SET' );
327
                $session->param( 'flags',      1 );
328
                $session->param( 'emailaddress',
329
                    C4::Context->preference('KohaAdminEmailAddress') );
330
                $session->param( 'ip',       $session->remote_addr() );
331
                $session->param( 'lasttime', time() );
332
                $userid = C4::Context->config('user');
321
                $userid = C4::Context->config('user');
322
323
                C4::Context->setup_session({
324
                    session => $session,
325
                    data => {
326
                        'number',       0,
327
                        'id',           $userid,
328
                        'cardnumber',   $userid,
329
                        'firstname',    $userid,
330
                        'surname',      $userid,
331
                        'branch',       'NO_LIBRARY_SET',
332
                        'branchname',   'NO_LIBRARY_SET',
333
                        'flags',        1,
334
                        'emailaddress', C4::Context->preference('KohaAdminEmailAddress'),
335
                        'interface',    undef,
336
                    },
337
                });
333
            }
338
            }
334
        }
339
        }
335
        else {
340
        else {
336
- 

Return to bug 31050