1 package OpenILS::Reporter::Proxy;
2 use strict; use warnings;
6 use Apache2::Const -compile => qw(OK BAD_REQUEST NOT_FOUNE 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');
34 my $user = verify_user($auth_ses);
35 return Apache2::Const::BAD_REQUEST unless ($user);
37 my $failures = OpenSRF::AppSession
38 ->create('open-ils.actor')
39 ->request('open-ils.actor.user.perm.check', $token, $user->id, 1, ['RUN_REPORTS'])
42 return Apache2::Const::BAD_REQUEST if (@$failures > 0);
44 # they're good, let 'em through
45 return Apache2::Const::DECLINED if (-e $apache->filename);
47 # oops, file not found
48 return Apache2::Const::NOT_FOUND;
51 # returns the user object if the session is valid, 0 otherwise
53 my $auth_token = shift;
54 return 0 unless $auth_token;
56 my $session = OpenSRF::AppSession
57 ->create("open-ils.auth")
58 ->request( "open-ils.auth.session.retrieve", $auth_token )
61 if (ref($user) eq 'HASH' && $user->{ilsevent} == 1001) {
65 return $user if ref($user);