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

(-)a/C4/Auth.pm (-16 / +30 lines)
Lines 32-54 use C4::Koha; Link Here
32
use C4::Branch; # GetBranches
32
use C4::Branch; # GetBranches
33
use C4::VirtualShelves;
33
use C4::VirtualShelves;
34
use POSIX qw/strftime/;
34
use POSIX qw/strftime/;
35
use List::MoreUtils qw/ any /;
35
36
36
# use utf8;
37
# use utf8;
37
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout);
38
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout);
38
39
39
BEGIN {
40
BEGIN {
40
    $VERSION = 3.02;        # set version for version checking
41
    sub psgi_env { any { /^psgi\./ } keys %ENV }
41
    $debug = $ENV{DEBUG};
42
    sub safe_exit {
42
    @ISA   = qw(Exporter);
43
	if ( psgi_env ) { die 'psgi:exit' }
43
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
44
	else { exit }
44
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &get_all_subpermissions &get_user_subpermissions);
45
    }
45
    %EXPORT_TAGS = (EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)]);
46
46
    $ldap = C4::Context->config('useldapserver') || 0;
47
    $VERSION     = 3.02;                                                                                                            # set version for version checking
47
    $cas = C4::Context->preference('casAuthentication');
48
    $debug       = $ENV{DEBUG};
48
    $caslogout = C4::Context->preference('casLogout');
49
    @ISA         = qw(Exporter);
50
    @EXPORT      = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
51
    @EXPORT_OK   = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &get_all_subpermissions &get_user_subpermissions);
52
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
53
    $ldap        = C4::Context->config('useldapserver') || 0;
54
    $cas         = C4::Context->preference('casAuthentication');
55
    $caslogout   = C4::Context->preference('casLogout');
49
    if ($ldap) {
56
    if ($ldap) {
50
        require C4::Auth_with_ldap;             # no import
57
	require C4::Auth_with_ldap;
51
        import  C4::Auth_with_ldap qw(checkpw_ldap);
58
	# no import import C4::Auth_with_ldap qw(checkpw_ldap);
52
    }
59
    }
53
    if ($cas) {
60
    if ($cas) {
54
        require C4::Auth_with_cas;             # no import
61
        require C4::Auth_with_cas;             # no import
Lines 547-554 sub _version_check ($$) { Link Here
547
	if (C4::Context->preference('OpacMaintenance') && $type eq 'opac') {
554
	if (C4::Context->preference('OpacMaintenance') && $type eq 'opac') {
548
        warn "OPAC Install required, redirecting to maintenance";
555
        warn "OPAC Install required, redirecting to maintenance";
549
        print $query->redirect("/cgi-bin/koha/maintenance.pl");
556
        print $query->redirect("/cgi-bin/koha/maintenance.pl");
550
      }
557
    }
551
      exit;
558
    unless ( $version = C4::Context->preference('Version') ) {    # assignment, not comparison
559
        if ( $type ne 'opac' ) {
560
            warn "Install required, redirecting to Installer";
561
            print $query->redirect("/cgi-bin/koha/installer/install.pl");
562
        } else {
563
            warn "OPAC Install required, redirecting to maintenance";
564
            print $query->redirect("/cgi-bin/koha/maintenance.pl");
565
        }
566
        safe_exit;
552
    }
567
    }
553
568
554
    # check that database and koha version are the same
569
    # check that database and koha version are the same
Lines 568-574 sub _version_check ($$) { Link Here
568
            warn sprintf("OPAC: " . $warning, 'maintenance');
583
            warn sprintf("OPAC: " . $warning, 'maintenance');
569
            print $query->redirect("/cgi-bin/koha/maintenance.pl");
584
            print $query->redirect("/cgi-bin/koha/maintenance.pl");
570
        }
585
        }
571
        exit;
586
        safe_exit;
572
    }
587
    }
573
}
588
}
574
589
Lines 984-990 sub checkauth { Link Here
984
        -cookie => $cookie
999
        -cookie => $cookie
985
      ),
1000
      ),
986
      $template->output;
1001
      $template->output;
987
    exit;
1002
    safe_exit;
988
}
1003
}
989
1004
990
=head2 check_api_auth
1005
=head2 check_api_auth
991
- 

Return to bug 5630