[LON-CAPA-cvs] cvs: loncom /interface createaccount.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 24 Mar 2008 05:15:15 -0000
This is a MIME encoded message
--raeburn1206335715
Content-Type: text/plain
raeburn Mon Mar 24 01:15:15 2008 EDT
Modified files:
/loncom/interface createaccount.pm
Log:
- Functionality for requesting user information from a user authenticated by a domain's default authentication (must be either Kerberos of localauth) moved to new &username_check() subroutine.
- Remove $reqtime - not used
- Add missing space in message displayed when token information is incomplete.
--raeburn1206335715
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080324011515.txt"
Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.3 loncom/interface/createaccount.pm:1.4
--- loncom/interface/createaccount.pm:1.3 Fri Mar 7 23:17:11 2008
+++ loncom/interface/createaccount.pm Mon Mar 24 01:15:14 2008
@@ -3,7 +3,7 @@
# institutional log-in ID (institutional authentication required - localauth
# or kerberos) or an e-mail address.
#
-# $Id: createaccount.pm,v 1.3 2008/03/08 04:17:11 raeburn Exp $
+# $Id: createaccount.pm,v 1.4 2008/03/24 05:15:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -57,6 +57,7 @@
my $contact_email = $r->dir_config('lonSupportEMail');
my $lonhost = $r->dir_config('lonHostID');
my $include = $r->dir_config('lonIncludes');
+ my $start_page;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token','courseid']);
&Apache::lonacc::get_posted_cgi($r);
@@ -64,7 +65,7 @@
my $handle = &Apache::lonnet::check_for_valid_session($r);
if ($handle ne '') {
- my $start_page =
+ $start_page =
&Apache::loncommon::start_page('Already logged in');
my $end_page =
&Apache::loncommon::end_page();
@@ -73,7 +74,14 @@
'</p><p><a href="/adm/loginproblems.html">'.&mt('Problems?').'</a></p>'.$end_page);
return OK;
}
-
+ $start_page =
+ &Apache::loncommon::start_page('Create a user account in LON-CAPA','',
+ {'no_inline_link' => 1,});
+ if ($env{'form.phase'} eq 'username_activation') {
+ if ($env{'form.udom'} ne '') {
+ $domain = $env{'form.udom'};
+ }
+ }
my $cancreate;
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
if (ref($domconfig{'usercreation'}) eq 'HASH') {
@@ -84,10 +92,6 @@
}
}
- my $start_page =
- &Apache::loncommon::start_page('Create a user account in LON-CAPA','',
- {
- 'no_inline_link' => 1,});
if (!$cancreate) {
&print_header($r,$start_page);
my $output = &mt('Creation of a new user account using an e-mail address as username or a loginID from your institution is not permitted in the domain: [_1] ([_2]).',$domain,$domdesc);
@@ -96,12 +100,12 @@
return OK;
}
- my $token = $env{'form.token'};
my ($output,$nostart,$noend);
+ my $token = $env{'form.token'};
if ($token) {
($output,$nostart,$noend) =
&process_mailtoken($r,$token,$contact_name,$contact_email,$domain,
- $domain,$domdesc,$lonhost,$include,$start_page);
+ $domdesc,$lonhost,$include,$start_page);
if ($nostart) {
if ($noend) {
return OK;
@@ -425,15 +429,14 @@
if (($data{'time'} =~ /^\d+$/) &&
($data{'domain'} ne '') &&
($data{'username'} =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/)) {
- my $reqtime = localtime($data{'time'});
if ($now - $data{'time'} < 7200) {
if ($env{'form.phase'} eq 'createaccount') {
my ($result,$output) = &create_account($r,$domain,$lonhost,
$data{'username'},$domdesc);
if ($result eq 'ok') {
$msg = $output;
- my $now = localtime(time);
- my $mailmsg = &mt('A LON-CAPA account in the [_1] domain has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$now,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n";
+ my $shownow = localtime($now);
+ my $mailmsg = &mt('A LON-CAPA account in the [_1] domain has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n";
my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'},
$mailmsg,$contact_name,
$contact_email);
@@ -458,9 +461,9 @@
}
} else {
$msg = &mt('Sorry, the token generated when you requested creation of an account has expired. Please submit a <a href="/adm/createaccount">new request</a>, and follow the link to the web page included in the new e-mail that will be sent to you, to allow you to create the account.');
- }
+ }
} else {
- $msg .= &mt('Sorry, the URL generated when you requested creation of an accountcontained incomplete information. Please submit a <a href="/adm/createaccount">new request</a> for creation of an account, and use the new URL that will be sent to your e-mail address to complete the process.');
+ $msg .= &mt('Sorry, the URL generated when you requested creation of an account contained incomplete information. Please submit a <a href="/adm/createaccount">new request</a> for creation of an account, and use the new URL that will be sent to your e-mail address to complete the process.');
}
return ($msg,$nostart,$noend);
}
@@ -647,42 +650,7 @@
$authok = 'non_authorized';
}
if ($authok eq 'authorized') {
- my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
- $newuser = 1;
- my $checkhash;
- my $checks = { 'username' => 1 };
- $checkhash->{$username.':'.$domain} = { 'newuser' => $newuser };
- &Apache::loncommon::user_rule_check($checkhash,$checks,
- \%alerts,\%rulematch,\%inst_results,\%curr_rules,\%got_rules);
- if (ref($alerts{'username'}) eq 'HASH') {
- if (ref($alerts{'username'}{$domain}) eq 'HASH') {
- if ($alerts{'username'}{$domain}{$username}) {
- my $userchkmsg;
- if (ref($curr_rules{$domain}) eq 'HASH') {
- $userchkmsg =
- &Apache::loncommon::instrule_disallow_msg('username',
- $domdesc,1).
- &Apache::loncommon::user_rule_formats($domain,
- $domdesc,$curr_rules{$domain}{'username'},
- 'username');
- }
- return $userchkmsg;
- }
- }
- }
- my $submit_text = &mt('Create LON-CAPA account');
- # FIXME need a cookie to confirm credentials were validated.
- $output =
- '<form method="post" action="/adm/createaccount">'.
- &Apache::loncreateuser::personal_data_display($username,$domain,1,
- undef,$inst_results{$username.':'.$domain}).
- '<br /><br /><input type="hidden" name="uname" value="'.$username.'" />'.
- '<input type="hidden" name="phase" value="username_activation" />';
- if ($courseid ne '') {
- $output .= '<input type="hidden" name="courseid" value="'.$courseid.'" />';
- }
- $output .= '<input type="submit" name="newaccount" value="'.
- $submit_text.'" /></form>';
+ $output = &username_check($username,$domain,$domdesc,$courseid);
} else {
$output = &mt('Not authenticated').' '.&mt('Please check the username and password');
}
@@ -690,6 +658,45 @@
return $output;
}
+sub username_check {
+ my ($username,$domain,$domdesc,$courseid) = @_;
+ my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
+ $newuser = 1;
+ my $checkhash;
+ my $checks = { 'username' => 1 };
+ $checkhash->{$username.':'.$domain} = { 'newuser' => $newuser };
+ &Apache::loncommon::user_rule_check($checkhash,$checks,\%alerts,\%rulematch,
+ \%inst_results,\%curr_rules,\%got_rules);
+ if (ref($alerts{'username'}) eq 'HASH') {
+ if (ref($alerts{'username'}{$domain}) eq 'HASH') {
+ if ($alerts{'username'}{$domain}{$username}) {
+ my $userchkmsg;
+ if (ref($curr_rules{$domain}) eq 'HASH') {
+ $userchkmsg =
+ &Apache::loncommon::instrule_disallow_msg('username',$domdesc,1).
+ &Apache::loncommon::user_rule_formats($domain,$domdesc,
+ $curr_rules{$domain}{'username'},'username');
+ }
+ return $userchkmsg;
+ }
+ }
+ }
+ my $submit_text = &mt('Create LON-CAPA account');
+ # FIXME need a cookie to confirm credentials were validated.
+ my $output = '<form method="post" action="/adm/createaccount">'.
+ &Apache::loncreateuser::personal_data_display($username,$domain,1,
+ undef,$inst_results{$username.':'.$domain}).
+ '<br /><br /><input type="hidden" name="uname" value="'.$username.'" />'."\n".
+ '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".
+ '<input type="hidden" name="phase" value="username_activation" />';
+ if ($courseid ne '') {
+ $output .= '<input type="hidden" name="courseid" value="'.$courseid.'" />';
+ }
+ $output .= '<input type="submit" name="newaccount" value="'.
+ $submit_text.'" /></form>';
+ return $output;
+}
+
sub username_activation {
my ($r,$username,$domain,$domdesc,$lonhost,$courseid) = @_;
my $output;
--raeburn1206335715--