[LON-CAPA-cvs] cvs: loncom(loncapaMITrelate_1) /interface createaccount.pm

raeburn raeburn at source.lon-capa.org
Mon Feb 13 12:22:56 EST 2012


raeburn		Mon Feb 13 17:22:56 2012 EDT

  Modified files:              (Branch: loncapaMITrelate_1)
    /loncom/interface	createaccount.pm 
  Log:
  - Customization for MITrelate
    - retrieve reCAPTCHA keys from Apache config.
  
  
Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.40.2.5.2.5 loncom/interface/createaccount.pm:1.40.2.5.2.6
--- loncom/interface/createaccount.pm:1.40.2.5.2.5	Mon Feb 13 05:24:22 2012
+++ loncom/interface/createaccount.pm	Mon Feb 13 17:22:56 2012
@@ -3,7 +3,7 @@
 # institutional log-in ID (institutional authentication required - localauth
 #  or kerberos) or an e-mail address.
 #
-# $Id: createaccount.pm,v 1.40.2.5.2.5 2012/02/13 05:24:22 raeburn Exp $
+# $Id: createaccount.pm,v 1.40.2.5.2.6 2012/02/13 17:22:56 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -57,6 +57,8 @@
 
     my $sso_username = $r->subprocess_env->get('REDIRECT_SSOUserUnknown');
     my $sso_domain = $r->subprocess_env->get('REDIRECT_SSOUserDomain');
+    my $privkey = $r->subprocess_env->get('reCAPTCHA_PRIVATE');
+    my $pubkey  = $r->subprocess_env->get('reCAPTCHA_PUBLIC')
 
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token','courseid']);
     &Apache::lonacc::get_posted_cgi($r);
@@ -225,7 +227,7 @@
         $output = &process_email_request($env{'form.useremail'},$domain,$domdesc,
                                          $contact_name,$contact_email,$cancreate,
                                          $lonhost,$domconfig{'usercreation'},
-                                         $courseid);
+                                         $courseid,$privkey);
     } elsif (!$token) {
         &print_header($r,$start_page,$courseid);
         my $now=time;
@@ -238,7 +240,7 @@
             $r->print(&javascript_validmail());
         }
         $output = &print_username_form($domain,$domdesc,$cancreate,$now,$lonhost,
-                                       $courseid);
+                                       $courseid,$pubkey);
     }
     $r->print($output);
     &print_footer($r);
@@ -398,7 +400,7 @@
 }
 
 sub print_username_form {
-    my ($domain,$domdesc,$cancreate,$now,$lonhost,$courseid) = @_;
+    my ($domain,$domdesc,$cancreate,$now,$lonhost,$courseid,$pubkey) = @_;
     my %lt = &Apache::lonlocal::texthash (
         unam   => 'username',
         udom   => 'domain',
@@ -433,7 +435,7 @@
                         $lt{'inst'}.'<br />'.
                         $lt{'aftr'}.'<br />'.
                         $lt{'thes'}.'<br />';
-            my $captchaform = &create_recaptcha();
+            my $captchaform = &create_recaptcha($pubkey);
             if ($captchaform) {
                 my $submit_text = &mt('Sign-up');
                 my $emailform = '<input type="text" name="useremail" size="25" value="" />';
@@ -527,7 +529,7 @@
 
 sub process_email_request {
     my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate,
-        $server,$settings,$courseid) = @_;
+        $server,$settings,$courseid,$privkey) = @_;
     $useremail = lc($env{'form.useremail'});
     my $output;
     if (ref($cancreate) eq 'ARRAY') {
@@ -549,7 +551,7 @@
                  my $captcha = Captcha::reCAPTCHA->new;
                  my $captcha_result =
                      $captcha->check_answer(
-                                            'PRIVATEKEY',
+                                            $privkey,
                                             $ENV{'REMOTE_ADDR'},
                                             $env{'form.recaptcha_challenge_field'},
                                             $env{'form.recaptcha_response_field'},
@@ -1210,10 +1212,11 @@
 }
 
 sub create_recaptcha {
+    my ($pubkey) = @_;
     my $captcha = Captcha::reCAPTCHA->new;
     # generate PUBLICKEY from https://www.google.com/recaptcha
     return $captcha->get_options_setter({theme => 'white'})."\n".
-           $captcha->get_html('PUBLICKEY');
+           $captcha->get_html($pubkey);
 }
 
 sub getkeys {




More information about the LON-CAPA-cvs mailing list