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

(-)a/C4/Auth.pm (-14 / +24 lines)
Lines 197-204 sub get_template_and_user { Link Here
197
        }
197
        }
198
    }
198
    }
199
199
200
    my $kick_out;
200
    if ( $in->{type} eq 'opac' && $user ) {
201
    if ( $in->{type} eq 'opac' && $user ) {
201
        my $kick_out;
202
202
203
        if (
203
        if (
204
# If the user logged in is the SCO user and they try to go out of the SCO module,
204
# If the user logged in is the SCO user and they try to go out of the SCO module,
Lines 257-268 sub get_template_and_user { Link Here
257
    }
257
    }
258
258
259
    my $borrowernumber;
259
    my $borrowernumber;
260
    my $patron;
260
    if ($user) {
261
    if ($user) {
261
262
262
        # It's possible for $user to be the borrowernumber if they don't have a
263
        # It's possible for $user to be the borrowernumber if they don't have a
263
        # userid defined (and are logging in through some other method, such
264
        # userid defined (and are logging in through some other method, such
264
        # as SSL certs against an email address)
265
        # as SSL certs against an email address)
265
        my $patron;
266
        $borrowernumber = getborrowernumber($user) if defined($user);
266
        $borrowernumber = getborrowernumber($user) if defined($user);
267
        if ( !defined($borrowernumber) && defined($user) ) {
267
        if ( !defined($borrowernumber) && defined($user) ) {
268
            $patron = Koha::Patrons->find( $user );
268
            $patron = Koha::Patrons->find( $user );
Lines 279-284 sub get_template_and_user { Link Here
279
        }
279
        }
280
280
281
        if ($patron->password_expired) {
281
        if ($patron->password_expired) {
282
            # Here we will force the user to the login page
282
            my $reset_template_name = ( $in->{type} eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt';
283
            my $reset_template_name = ( $in->{type} eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt';
283
            $template = C4::Templates::gettemplate( $reset_template_name, $in->{type},
284
            $template = C4::Templates::gettemplate( $reset_template_name, $in->{type},
284
                $in->{query} );
285
                $in->{query} );
Lines 297-314 sub get_template_and_user { Link Here
297
                script_name => get_script_name(),
298
                script_name => get_script_name(),
298
            );
299
            );
299
300
300
            print $in->{query}->header(
301
            # We still want to generate the global variables for the templates, so we will
301
                {
302
            # output the login page at the end of this routine
302
                    type              => 'text/html',
303
            $user = undef;
303
                    charset           => 'utf-8',
304
            $kick_out = 1;
304
                    cookie            => $cookie,
305
305
                    'X-Frame-Options' => 'SAMEORIGIN'
306
                }
307
              ),
308
              $template->output;
309
            safe_exit;
310
        }
306
        }
307
    }
311
308
309
    if( $user ) {
312
        # user info
310
        # user info
313
        $template->param( loggedinusername   => $user ); # OBSOLETE - Do not reuse this in template, use logged_in_user.userid instead
311
        $template->param( loggedinusername   => $user ); # OBSOLETE - Do not reuse this in template, use logged_in_user.userid instead
314
        $template->param( loggedinusernumber => $borrowernumber ); # FIXME Should be replaced with logged_in_user.borrowernumber
312
        $template->param( loggedinusernumber => $borrowernumber ); # FIXME Should be replaced with logged_in_user.borrowernumber
Lines 658-664 sub get_template_and_user { Link Here
658
            PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
656
            PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
659
            useDischarge                 => C4::Context->preference('useDischarge'),
657
            useDischarge                 => C4::Context->preference('useDischarge'),
660
        );
658
        );
661
662
        $template->param( OpacPublic => '1' ) if ( $user || C4::Context->preference("OpacPublic") );
659
        $template->param( OpacPublic => '1' ) if ( $user || C4::Context->preference("OpacPublic") );
663
    }
660
    }
664
661
Lines 676-681 sub get_template_and_user { Link Here
676
        }
673
        }
677
    }
674
    }
678
675
676
    if( $kick_out ){
677
        # Output to auth page if user has been forcibly logged out
678
        # due to password expiration
679
        print $in->{query}->header(
680
            {
681
                type              => 'text/html',
682
                charset           => 'utf-8',
683
                cookie            => $cookie,
684
                'X-Frame-Options' => 'SAMEORIGIN'
685
            }
686
          ),
687
        $template->output;
688
        safe_exit;
689
    }
679
    return ( $template, $borrowernumber, $cookie, $flags );
690
    return ( $template, $borrowernumber, $cookie, $flags );
680
}
691
}
681
692
682
- 

Return to bug 29924