1 package OpenILS::Reporter::Proxy;
2 use strict; use warnings;
6 use Apache2::Const -compile => qw(OK NOT_FOUND DECLINED :log);
7 use APR::Const -compile => qw(:error SUCCESS);
11 use OpenSRF::EX qw(:try);
15 # set the bootstrap config and template include directory when
16 # this module is loaded
26 OpenSRF::System->bootstrap_client( config_file => $bootstrap );
32 my $auth_ses = $cgi->cookie('ses');
33 my $ws_ou = $cgi->cookie('ws_ou') || 1;
35 my $user = verify_login($auth_ses);
36 return Apache2::Const::NOT_FOUND unless ($user);
38 my $failures = OpenSRF::AppSession
39 ->create('open-ils.actor')
40 ->request('open-ils.actor.user.perm.check', $auth_ses, $user->id, $ws_ou, ['RUN_REPORTS'])
43 return Apache2::Const::NOT_FOUND if (@$failures > 0);
45 # they're good, let 'em through
46 return Apache2::Const::DECLINED if (-e $apache->filename);
48 # oops, file not found
49 return Apache2::Const::NOT_FOUND;
52 # returns the user object if the session is valid, 0 otherwise
54 my $auth_token = shift;
55 return 0 unless $auth_token;
57 my $user = OpenSRF::AppSession
58 ->create("open-ils.auth")
59 ->request( "open-ils.auth.session.retrieve", $auth_token )
62 if (ref($user) eq 'HASH' && $user->{ilsevent} == 1001) {
66 return $user if ref($user);