From: miker Date: Mon, 2 Oct 2006 05:33:05 +0000 (+0000) Subject: allow login when no cookie is present X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3f7345257924cb4e19d895d57c86911a7c9dd886;p=Evergreen.git allow login when no cookie is present git-svn-id: svn://svn.open-ils.org/ILS/trunk@6333 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Reporter/Proxy.pm b/Open-ILS/src/perlmods/OpenILS/Reporter/Proxy.pm index 2df7f0bc87..3789198560 100644 --- a/Open-ILS/src/perlmods/OpenILS/Reporter/Proxy.pm +++ b/Open-ILS/src/perlmods/OpenILS/Reporter/Proxy.pm @@ -32,6 +32,63 @@ sub handler { my $auth_ses = $cgi->cookie('ses'); my $ws_ou = $cgi->cookie('ws_ou') || 1; + if (!$auth_ses) { + my $u = $cgi->param('user'); + my $p = $cgi->param('passwd'); + + my $url = $cgi->url; + + if (!$u) { + if ($url =~ /^http:/o) { + $url =~ s/^http:/https:/o; + print "Location: $url\n\n"; + return 200; + } + + print <<" HTML"; +Content-type: text/html + + + + Report Output Login + + +
+ + + + + + + + + + + + +
Please log in to view reports
Username or barcode:
Password:
+ +
+ + + HTML + return 200; + } + + $auth_ses = oils_login($u, $p); + if ($auth_ses) { + print $cgi->redirect( + -uri=>$url, + -cookie=>$cgi->cookie( + -name=>'ses', + -value=>$auth_ses, + -path=>'/',-expires=>'+1h' + ) + ); + return 302; + } + } + my $user = verify_login($auth_ses); return Apache2::Const::NOT_FOUND unless ($user); @@ -67,6 +124,33 @@ sub verify_login { return undef; } +sub oils_login { + my( $username, $password, $type ) = @_; + + $type |= "staff"; + my $nametype = 'username'; + $nametype = 'barcode' if ($username =~ /^\d+$/o); + + my $seed = OpenSRF::AppSession + ->create("open-ils.auth") + ->request( 'open-ils.auth.authenticate.init', $username ) + ->gather(1); + + return undef unless $seed; + + my $response = OpenSRF::AppSession + ->create("open-ils.auth") + ->request( 'open-ils.auth.authenticate.complete', + { $nametype => $username, + password => md5_hex($seed . md5_hex($password)), + type => $type }) + ->gather(1); + + return undef unless $response; + + return = $response->{payload}->{authtoken}; +} + 1;