[LON-CAPA-cvs] cvs: loncom /auth lonstatusacc.pm /cgi loncgi.pm
raeburn
raeburn@source.lon-capa.org
Sun, 30 Nov 2008 14:47:18 -0000
raeburn Sun Nov 30 14:47:18 2008 EDT
Modified files:
/loncom/auth lonstatusacc.pm
/loncom/cgi loncgi.pm
Log:
- When calling loncgi::check_cookie_and_load_env() from a handler in mod_perl (i.e., lonstatusacc) pass in the request object as an argument to keep CGI::Cookie happy.
Index: loncom/auth/lonstatusacc.pm
diff -u loncom/auth/lonstatusacc.pm:1.1 loncom/auth/lonstatusacc.pm:1.2
--- loncom/auth/lonstatusacc.pm:1.1 Fri Nov 28 19:38:11 2008
+++ loncom/auth/lonstatusacc.pm Sun Nov 30 14:47:11 2008
@@ -1,7 +1,7 @@
#
# LON-CAPA authorization for pages generated by server-status reports
#
-# $Id: lonstatusacc.pm,v 1.1 2008/11/28 19:38:11 raeburn Exp $
+# $Id: lonstatusacc.pm,v 1.2 2008/11/30 14:47:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,7 +41,7 @@
my $page = 'serverstatus';
if ($r->uri eq '/adm/test') {
$page = 'showenv';
- if (&LONCAPA::loncgi::check_cookie_and_load_env()) {
+ if (&LONCAPA::loncgi::check_cookie_and_load_env($r)) {
if (&LONCAPA::loncgi::can_view($page)) {
return OK;
} elsif (&LONCAPA::loncgi::check_ipbased_access($page,$reqhost)) {
@@ -73,7 +73,7 @@
} elsif (&LONCAPA::loncgi::check_ipbased_access($page,$reqhost)) {
return OK;
} else {
- if (&LONCAPA::loncgi::check_cookie_and_load_env($page)) {
+ if (&LONCAPA::loncgi::check_cookie_and_load_env($r)) {
if (&LONCAPA::loncgi::can_view($page)) {
return OK;
}
Index: loncom/cgi/loncgi.pm
diff -u loncom/cgi/loncgi.pm:1.9 loncom/cgi/loncgi.pm:1.10
--- loncom/cgi/loncgi.pm:1.9 Fri Nov 28 20:39:43 2008
+++ loncom/cgi/loncgi.pm Sun Nov 30 14:47:18 2008
@@ -1,7 +1,7 @@
#
# LON-CAPA helpers for cgi-bin scripts
#
-# $Id: loncgi.pm,v 1.9 2008/11/28 20:39:43 raeburn Exp $
+# $Id: loncgi.pm,v 1.10 2008/11/30 14:47:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -81,7 +81,8 @@
=item check_cookie_and_load_env()
-Inputs: none
+Inputs: 1 ( optional). When called from a handler in mod_perl,
+ pass in the request object.
Returns: 1 if the user has a LON-CAPA cookie 0 if not.
Loads the users environment into the %env hash if the cookie is correct.
@@ -91,7 +92,13 @@
#############################################
#############################################
sub check_cookie_and_load_env {
- my %cookies=fetch CGI::Cookie;
+ my ($r) = @_;
+ my %cookies;
+ if (ref($r)) {
+ %cookies = CGI::Cookie->fetch($r);
+ } else {
+ %cookies = CGI::Cookie->fetch();
+ }
if (exists($cookies{'lonID'}) &&
-e "$lonidsdir/".$cookies{'lonID'}->value.".id") {
# cookie found