[LON-CAPA-cvs] cvs: modules /raeburn/register DirectLogin.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Sat, 04 Feb 2006 01:15:01 -0000


raeburn		Fri Feb  3 20:15:01 2006 EDT

  Modified files:              
    /modules/raeburn/register	DirectLogin.pm 
  Log:
  Changes to make this work with Apache2.
  
  
Index: modules/raeburn/register/DirectLogin.pm
diff -u modules/raeburn/register/DirectLogin.pm:1.1 modules/raeburn/register/DirectLogin.pm:1.2
--- modules/raeburn/register/DirectLogin.pm:1.1	Wed Apr 27 12:59:54 2005
+++ modules/raeburn/register/DirectLogin.pm	Fri Feb  3 20:15:01 2006
@@ -1,10 +1,13 @@
 package Apache::LON::DirectLogin;
 
 use strict;
+use Apache::RequestRec();
+use Apache::RequestIO();
 use Storable qw(store retrieve dclone);
-use Apache::Constants qw(:common :http REDIRECT);
+use Apache::Const qw(:common :http REDIRECT);
 use CGI::Cookie();
 use Apache::LON::Session;
+use Apache::LON::processform;
 
 sub handler {
     my $r = shift;
@@ -36,19 +39,24 @@
         return SERVER_ERROR;
     }
 
-    $r->notes('_COOKIESTUFF' => $auth_name);
-    $r->notes('_AUTHFAIL' => 1);
+    $r->notes->set('_COOKIESTUFF' => $auth_name);
+    $r->notes->set('_AUTHFAIL' => 1);
 
-    my %params = ($r->args,$r->content);
-    my $logintoken = $params{'logintoken'};
+    my %params = ();
+    &Apache::LON::processform::postitems($r,\%params);
+    if ($r->args) {
+        &Apache::LON::processform::getitems($r->args,\%params);
+    }
+
+    my $logintoken = $params{'logintoken'}[0];
 
     if (($logintoken ne '') && (-e "/home/helpdesk/tokens/$logintoken")) {
         my $tokenhash = &Storable::retrieve("/home/helpdesk/tokens/$logintoken");
 #        unlink "/home/helpdesk/tokens/$logintoken";
 
         my $caller = $$tokenhash{'caller'};
-        $r->notes('_ORIGURL' => $caller);
-        $r->notes('_CURRURL' => $caller);
+        $r->notes->set('_ORIGURL' => $caller);
+        $r->notes->set('_CURRURL' => $caller);
 
         my $auth_cookie = new CGI::Cookie (
                                       -name => $r->auth_name,
@@ -57,16 +65,16 @@
                                      );
         my $now = time;
         if ($now - $$tokenhash{'created'} > 1800) {
-            $r->notes('_RejectAuth' => "Your token has expired. Please authenticate using the username and password provided in the e-mail sent to you.");
+            $r->notes->set('_RejectAuth' => "Your token has expired. Please authenticate using the username and password provided in the e-mail sent to you.");
 
         } else {
             if (&autologin($r,$dbh,\%attr,$tokenhash)) {
-                $r->notes('_AUTHFAIL' => 0);
+                $r->notes->set('_AUTHFAIL' => 0);
                 $r->err_headers_out->{'Set-cookie'} = $auth_cookie;
             }
         }
     } else {
-        $r->notes('_RejectAuth' => "A valid token was not provided. Please authenticate using the username and password provided in the e-mail sent to you.");
+        $r->notes->set('_RejectAuth' => "A valid token was not provided. Please authenticate using the username and password provided in the e-mail sent to you.");
     }
     $dbh->disconnect;
     return OK;
@@ -78,3 +86,5 @@
     my $status = &Apache::LON::Session::new_session($r,$dbh,$attr,$user,$auth_cookie);
     return $status;
 }
+
+1;