[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm

www lon-capa-cvs@mail.lon-capa.org
Sat, 08 May 2004 14:12:16 -0000


www		Sat May  8 10:12:16 2004 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  Continued work on key verification.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.88 loncom/auth/lonroles.pm:1.89
--- loncom/auth/lonroles.pm:1.88	Tue Mar  9 16:01:55 2004
+++ loncom/auth/lonroles.pm	Sat May  8 10:12:16 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.88 2004/03/09 21:01:55 www Exp $
+# $Id: lonroles.pm,v 1.89 2004/05/08 14:12:16 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -109,12 +109,46 @@
 # check for keyed access
 		    if (($role eq 'st') && 
                        ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {
-		         unless (&Apache::lonnet::validate_access_key(
+# who is key authority?
+			my $authdom=$cdom;
+			my $authnum=$cnum;
+			if ($ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
+			    ($authnum,$authdom)=
+				split(/\W/,$ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'});
+			}
+# check with key authority
+			unless (&Apache::lonnet::validate_access_key(
 				     $ENV{'environment.key.'.$cdom.'_'.$cnum},
-					     $cdom,$cnum)) {
+					     $authdom,$authnum)) {
 # there is no valid key
 			     if ($ENV{'form.newkey'}) {
 # student attempts to register a new key
+				 &Apache::loncommon::content_type($r,'text/html');
+				 &Apache::loncommon::no_cache($r);
+				 $r->send_http_header;
+				 my $swinfo=&Apache::lonmenu::rawconfig();
+				 my $bodytag=&Apache::loncommon::bodytag
+				    ('Verifying Access Key to Unlock this Course');
+				 my $buttontext=&mt('Re-Enter Key');
+				 my $message=&mt('Key Verification Failed').'<br /><a href="/adm/logout">'.
+				     &mt('Logout').'</a>';
+				 $r->print(<<ENDENTEREDKEY);
+<head><title>Verifying Course Access Key</title>
+</head>
+<html>
+$bodytag
+<script>
+$swinfo
+</script>
+<form method="post">
+<input type="hidden" name="selectrole" value="1" />
+<input type="hidden" name="$trolecode" value="1" />
+$message
+<input type="submit" value="$buttontext" />
+</form>
+</body></html>
+ENDENTEREDKEY
+                                 return OK;
 			     } else {
 # print form to enter a new key
 				 &Apache::loncommon::content_type($r,'text/html');
@@ -132,7 +166,8 @@
 $swinfo
 </script>
 <form method="post">
-<input type="hidden" name="selectrole" value="$ENV{'form.selectrole'}" />
+<input type="hidden" name="selectrole" value="1" />
+<input type="hidden" name="$trolecode" value="1" />
 <input type="text" size="20" name="newkey" value="$ENV{'form.newkey'}" />
 <input type="submit" value="Enter key" />
 </form>