- elsif ( $sessionID = $query->cookie("CGISESSID") )
- { # assignment, not comparison
- $session = get_session($sessionID);
- C4::Context->_new_userenv($sessionID);
- my ( $ip, $lasttime, $sessiontype );
- my $s_userid = '';
- if ($session) {
- $s_userid = $session->param('id') // '';
- C4::Context->set_userenv(
- $session->param('number'), $s_userid,
- $session->param('cardnumber'), $session->param('firstname'),
- $session->param('surname'), $session->param('branch'),
- $session->param('branchname'), $session->param('flags'),
- $session->param('emailaddress'),
- $session->param('shibboleth')
- );
- C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
- C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') );
- C4::Context::set_shelves_userenv( 'tot', $session->param('totshelves') );
- $debug and printf STDERR "AUTH_SESSION: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch);
- $ip = $session->param('ip');
- $lasttime = $session->param('lasttime');
- $userid = $s_userid;
- $sessiontype = $session->param('sessiontype') || '';
- }
- if ( ( $query->param('koha_login_context') && ( $q_userid ne $s_userid ) )
- || ( $cas && $query->param('ticket') && !C4::Context->userenv->{'id'} )
- || ( $shib && $shib_login && !$logout && !C4::Context->userenv->{'id'} )
- ) {
-
- #if a user enters an id ne to the id in the current session, we need to log them in...
- #first we need to clear the anonymous session...
- $debug and warn "query id = $q_userid but session id = $s_userid";
- $anon_search_history = $session->param('search_history');
- $session->delete();
- $session->flush;
- C4::Context->_unset_userenv($sessionID);
- $sessionID = undef;
- $userid = undef;
- }
- elsif ($logout) {
+ elsif ( $sessionID = $query->cookie("CGISESSID") ) { # assignment, not comparison
+ my ( $return, $more_info );
+ # NOTE: $flags in the following call is still undefined !
+ ( $return, $session, $more_info ) = check_cookie_auth( $sessionID, $flags,
+ { remote_addr => $ENV{REMOTE_ADDR}, skip_version_check => 1 }
+ );