version 1.32.2.1, 2009/09/14 15:33:48
|
version 1.40.2.1, 2010/08/16 14:39:20
|
Line 39 use Apache::lonhtmlcommon;
|
Line 39 use Apache::lonhtmlcommon;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonauth; |
use Apache::lonauth; |
use Apache::resetpw; |
use Apache::resetpw; |
use Captcha::reCAPTCHA; |
use Authen::Captcha; |
use DynaLoader; # for Crypt::DES version |
use DynaLoader; # for Crypt::DES version |
use Crypt::DES; |
use Crypt::DES; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
Line 63 sub handler {
|
Line 63 sub handler {
|
&Apache::lonlocal::get_language_handle($r); |
&Apache::lonlocal::get_language_handle($r); |
|
|
if ($sso_username ne '' && $sso_domain ne '') { |
if ($sso_username ne '' && $sso_domain ne '') { |
$domain = $sso_domain; |
$domain = $sso_domain; |
} else { |
} else { |
$domain = &Apache::lonnet::default_login_domain(); |
$domain = &Apache::lonnet::default_login_domain(); |
if (defined($env{'form.courseid'})) { |
if (defined($env{'form.courseid'})) { |
Line 92 sub handler {
|
Line 92 sub handler {
|
my $end_page = |
my $end_page = |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
$r->print($start_page."\n".'<h2>'.&mt('You are already logged in').'</h2>'. |
$r->print($start_page."\n".'<h2>'.&mt('You are already logged in').'</h2>'. |
'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]logout[_4].','<a href="/adm/roles">','</a>','<a href="/adm/logout">','</a>'). |
'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].','<a href="/adm/roles">','</a>','<a href="/adm/logout">','</a>'). |
'</p><p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'.$end_page); |
'</p><p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'.$end_page); |
return OK; |
return OK; |
} |
} |
Line 112 sub handler {
|
Line 112 sub handler {
|
if ($env{'form.udom'} ne '') { |
if ($env{'form.udom'} ne '') { |
$domain = $env{'form.udom'}; |
$domain = $env{'form.udom'}; |
} |
} |
|
|
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
|
my ($cancreate,$statustocreate) = |
|
&get_creation_controls($domain,$domconfig{'usercreation'}); |
|
|
my ($result,$output) = |
my ($result,$output) = |
&username_validation($r,$env{'form.uname'},$domain,$domdesc, |
&username_validation($r,$env{'form.uname'},$domain,$domdesc, |
$contact_name,$contact_email,$courseid, |
$contact_name,$contact_email,$courseid, |
$lonhost); |
$lonhost,$statustocreate); |
if ($result eq 'existingaccount') { |
if ($result eq 'existingaccount') { |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 133 sub handler {
|
Line 139 sub handler {
|
$start_page = |
$start_page = |
&Apache::loncommon::start_page($title,$js, |
&Apache::loncommon::start_page($title,$js, |
{'no_inline_link' => 1,}); |
{'no_inline_link' => 1,}); |
my @cancreate; |
my %domconfig = |
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
my ($cancreate,$statustocreate) = &get_creation_controls($domain,$domconfig{'usercreation'}); |
if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { |
if (@{$cancreate} == 0) { |
if (ref($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}) eq 'ARRAY') { |
|
@cancreate = @{$domconfig{'usercreation'}{'cancreate'}{'selfcreate'}}; |
|
} elsif (($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') && |
|
($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne '')) { |
|
@cancreate = ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}); |
|
} |
|
} |
|
} |
|
|
|
if (@cancreate == 0) { |
|
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
'<span class="LC_warning">'. |
'<span class="LC_warning">'. |
&mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted for the GCI WebCenter.').'</span><br /><br />'; |
&mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted at this institution ([_1]).',$domdesc).'</span><br /><br />'; |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
return OK; |
return OK; |
Line 160 sub handler {
|
Line 156 sub handler {
|
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
my ($msg,$sso_logout); |
my ($msg,$sso_logout); |
$sso_logout = &sso_logout_frag($r,$domain); |
$sso_logout = &sso_logout_frag($r,$domain); |
if (grep(/^sso$/,@cancreate)) { |
if (grep(/^sso$/,@{$cancreate})) { |
$msg = '<h3>'.&mt('Account creation').'</h3>'. |
$msg = '<h3>'.&mt('Account creation').'</h3>'. |
&mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution.").'<br />'; |
&mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution.").'<br />'; |
|
|
$msg .= &username_check($sso_username,$domain,$domdesc,$courseid, |
$msg .= &username_check($sso_username,$domain,$domdesc,$courseid, |
$lonhost,$contact_email,$contact_name,$sso_logout); |
$lonhost,$contact_email,$contact_name, |
|
$sso_logout,$statustocreate); |
} else { |
} else { |
$msg = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
$msg = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
'<span class="LC_warning">'.&mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution, and you are not permitted to create one.").'</span><br /><br />'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).'<hr />'. |
'<span class="LC_warning">'.&mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution, and you are not permitted to create one.").'</span><br /><br />'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).'<hr />'. |
Line 215 sub handler {
|
Line 212 sub handler {
|
(my $result,$output) = |
(my $result,$output) = |
&username_validation($r,$env{'form.uname'},$domain,$domdesc, |
&username_validation($r,$env{'form.uname'},$domain,$domdesc, |
$contact_name,$contact_email,$courseid, |
$contact_name,$contact_email,$courseid, |
$lonhost); |
$lonhost,$statustocreate); |
if ($result eq 'existingaccount') { |
if ($result eq 'existingaccount') { |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 226 sub handler {
|
Line 223 sub handler {
|
} elsif ($env{'form.create_with_email'}) { |
} elsif ($env{'form.create_with_email'}) { |
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
$output = &process_email_request($env{'form.useremail'},$domain,$domdesc, |
$output = &process_email_request($env{'form.useremail'},$domain,$domdesc, |
$contact_name,$contact_email,\@cancreate, |
$contact_name,$contact_email,$cancreate, |
$lonhost,$domconfig{'usercreation'}, |
$lonhost,$domconfig{'usercreation'}, |
$courseid); |
$courseid); |
} elsif (!$token) { |
} elsif (!$token) { |
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
my $now=time; |
my $now=time; |
if (grep(/^login$/,@cancreate)) { |
if (grep(/^login$/,@{$cancreate})) { |
my $jsh=Apache::File->new($include."/londes.js"); |
my $jsh=Apache::File->new($include."/londes.js"); |
$r->print(<$jsh>); |
$r->print(<$jsh>); |
$r->print(&javascript_setforms($now)); |
$r->print(&javascript_setforms($now)); |
} |
} |
if (grep(/^email$/,@cancreate)) { |
if (grep(/^email$/,@{$cancreate})) { |
$r->print(&javascript_validmail()); |
$r->print(&javascript_validmail()); |
} |
} |
$output = &print_username_form($domain,$domdesc,\@cancreate,$now,$lonhost, |
$output = &print_username_form($domain,$domdesc,$cancreate,$now,$lonhost, |
$courseid); |
$courseid); |
} |
} |
$r->print($output); |
$r->print($output); |
Line 280 sub selfenroll_crumbs {
|
Line 277 sub selfenroll_crumbs {
|
my ($r,$courseid,$desc) = @_; |
my ($r,$courseid,$desc) = @_; |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:ToCatalog('backupcrumbs','')", |
({href=>"javascript:ToCatalog('backupcrumbs','')", |
text=>"Course Catalog"}); |
text=>"Course/Community Catalog"}); |
if ($env{'form.coursenum'} ne '') { |
if ($env{'form.coursenum'} ne '') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:ToCatalog('backupcrumbs','details')", |
({href=>"javascript:ToCatalog('backupcrumbs','details')", |
Line 405 sub print_username_form {
|
Line 402 sub print_username_form {
|
} |
} |
if (grep(/^email$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
$output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>'; |
$output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>'; |
my $captchaform = &create_recaptcha(); |
my $captchaform = &create_captcha(); |
if ($captchaform) { |
if ($captchaform) { |
my $submit_text = &mt('Request LON-CAPA account'); |
my $submit_text = &mt('Request LON-CAPA account'); |
my $emailform = '<input type="text" name="useremail" size="25" value="" />'; |
my $emailform = '<input type="text" name="useremail" size="25" value="" />'; |
Line 476 sub login_box {
|
Line 473 sub login_box {
|
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_title(&mt('Password'), |
&Apache::lonhtmlcommon::row_title(&mt('Password'), |
'LC_pick_box_title')."\n". |
'LC_pick_box_title')."\n". |
$upassform."\n".'<br /><br />'."\n". |
$upassform; |
'<input type="button" name="username_validation" value="'. |
if ($context eq 'selfenroll') { |
$submit_text.'" onclick="javascript:send()" />'."\n". |
my $udomform = '<input type="text" name="udom" size="10" value="'. |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
$domain.'" />'; |
&Apache::lonhtmlcommon::end_pick_box()."\n". |
$output .= &Apache::lonhtmlcommon::row_closure(1)."\n". |
'<p><a href="/adm/resetpw">'.&mt('Forgot password?').'</a>'. |
&Apache::lonhtmlcommon::row_title(&mt('Domain'), |
'</p>'."\n". |
'LC_pick_box_title')."\n". |
'<input type="hidden" name="lextkey" value="'.$lextkey.'">'."\n". |
$udomform."\n"; |
'<input type="hidden" name="uextkey" value="'.$uextkey.'">'."\n". |
} else { |
|
$output .= '<input type="hidden" name="udom" value="'.$domain.'" />'; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::row_title(). |
|
'<br /><input type="submit" name="username_validation" value="'. |
|
$submit_text.'" />'."\n"; |
|
if ($context eq 'selfenroll') { |
|
$output .= '<br /><br /><table width="100%"><tr><td align="right">'. |
|
'<span class="LC_fontsize_medium">'. |
|
'<a href="/adm/resetpw">'.&mt('Forgot password?').'</a>'. |
|
'</span></td></tr></table>'."\n"; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::end_pick_box().'<br />'."\n"; |
|
$output .= '<input type="hidden" name="lextkey" value="'.$lextkey.'" />'."\n". |
|
'<input type="hidden" name="uextkey" value="'.$uextkey.'" />'."\n". |
'</form>'; |
'</form>'; |
return $output; |
return $output; |
} |
} |
Line 510 sub process_email_request {
|
Line 523 sub process_email_request {
|
$contact_name,$contact_email); |
$contact_name,$contact_email); |
return $output; |
return $output; |
} else { |
} else { |
my $captcha = Captcha::reCAPTCHA->new; |
my $code = $env{'form.code'}; |
my $captcha_result = |
my $md5sum = $env{'form.crypt'}; |
$captcha->check_answer( |
my %captcha_params = &captcha_settings(); |
'PRIVATEKEY', |
my $captcha = Authen::Captcha->new( |
$ENV{'REMOTE_ADDR'}, |
output_folder => $captcha_params{'output_dir'}, |
$env{'form.recaptcha_challenge_field'}, |
data_folder => $captcha_params{'db_dir'}, |
$env{'form.recaptcha_response_field'}, |
); |
); # generate private key for IP |
my $captcha_chk = $captcha->check_code($code,$md5sum); |
# from http://recaptcha.net/ |
my %captcha_hash = ( |
if (!$captcha_result->{is_valid}) { |
0 => 'Code not checked (file error)', |
|
-1 => 'Failed: code expired', |
|
-2 => 'Failed: invalid code (not in database)', |
|
-3 => 'Failed: invalid code (code does not match crypt)', |
|
); |
|
if ($captcha_chk != 1) { |
$output = &invalid_state('captcha',$domdesc,$contact_name, |
$output = &invalid_state('captcha',$domdesc,$contact_name, |
$contact_email); |
$contact_email,$captcha_hash{$captcha_chk}); |
return $output; |
return $output; |
} |
} |
my $uhome=&Apache::lonnet::homeserver($useremail,$domain); |
my $uhome=&Apache::lonnet::homeserver($useremail,$domain); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); |
&call_rulecheck($useremail,$domain,\%alerts,\%rulematch, |
&call_rulecheck($useremail,$domain,\%alerts,\%rulematch, |
\%inst_results,\%curr_rules,%got_rules,'username'); |
\%inst_results,\%curr_rules,\%got_rules,'username'); |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if ($alerts{'username'}{$domain}{$useremail}) { |
if ($alerts{'username'}{$domain}{$useremail}) { |
Line 584 sub send_token {
|
Line 602 sub send_token {
|
if ($token !~ /^error/ && $token ne 'no_such_host') { |
if ($token !~ /^error/ && $token ne 'no_such_host') { |
my $esc_token = &escape($token); |
my $esc_token = &escape($token); |
my $showtime = localtime(time); |
my $showtime = localtime(time); |
my $mailmsg = &mt('A request was submitted on [_1] for creation of a GCI WebCenter account.',$showtime).' '. |
my $mailmsg = &mt('A request was submitted on [_1] for creation of a LON-CAPA account at the following institution: [_2].',$showtime,$domdesc).' '. |
&mt('To complete this process please open a web browser and enter the following URL in the address/location box: [_1]', |
&mt('To complete this process please open a web browser and enter the following URL in the address/location box: [_1]', |
&Apache::lonnet::absolute_url().'/adm/createaccount?token='.$esc_token); |
&Apache::lonnet::absolute_url().'/adm/createaccount?token='.$esc_token); |
my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name, |
my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name, |
Line 626 sub process_mailtoken {
|
Line 644 sub process_mailtoken {
|
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$msg = $output; |
$msg = $output; |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
my $mailmsg = &mt('A GCI WebCenter account has been created [_1] from IP address: [_2]. If you did not perform this action or authorize it, please contact the [_3] ([_4]).',$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n"; |
my $mailmsg = &mt('A LON-CAPA account for the institution: [_1] 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'}, |
my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'}, |
$mailmsg,$contact_name, |
$mailmsg,$contact_name, |
$contact_email); |
$contact_email); |
Line 707 sub print_dataentry_form {
|
Line 725 sub print_dataentry_form {
|
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount', |
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount', |
$lonhost); |
$lonhost); |
my $formtag = '<form name="server" method="post" target="_top" action="/adm/createaccount">'; |
my $formtag = '<form name="server" method="post" target="_top" action="/adm/createaccount">'; |
my ($datatable,$rowcount,$editable) = |
my ($datatable,$rowcount) = |
&Apache::loncreateuser::personal_data_display($username,$domain, |
&Apache::loncreateuser::personal_data_display($username,$domain, |
'email','selfcreate'); |
'email','selfcreate'); |
if ($rowcount) { |
if ($rowcount) { |
Line 771 ENDSERVERFORM
|
Line 789 ENDSERVERFORM
|
return $output; |
return $output; |
} |
} |
|
|
|
sub get_creation_controls { |
|
my ($domain,$usercreation) = @_; |
|
my (@cancreate,@statustocreate); |
|
if (ref($usercreation) eq 'HASH') { |
|
if (ref($usercreation->{'cancreate'}) eq 'HASH') { |
|
if (ref($usercreation->{'cancreate'}{'statustocreate'}) eq 'ARRAY') { |
|
@statustocreate = @{$usercreation->{'cancreate'}{'statustocreate'}}; |
|
} else { |
|
@statustocreate = ('default'); |
|
my ($othertitle,$usertypes,$types) = |
|
&Apache::loncommon::sorted_inst_types($domain); |
|
if (ref($types) eq 'ARRAY') { |
|
push(@statustocreate,@{$types}); |
|
} |
|
} |
|
if (ref($usercreation->{'cancreate'}{'selfcreate'}) eq 'ARRAY') { |
|
@cancreate = @{$usercreation->{'cancreate'}{'selfcreate'}}; |
|
} elsif (($usercreation->{'cancreate'}{'selfcreate'} ne 'none') && |
|
($usercreation->{'cancreate'}{'selfcreate'} ne '')) { |
|
@cancreate = ($usercreation->{'cancreate'}{'selfcreate'}); |
|
} |
|
} |
|
} |
|
return (\@cancreate,\@statustocreate); |
|
} |
|
|
sub create_account { |
sub create_account { |
my ($r,$domain,$lonhost,$username,$domdesc) = @_; |
my ($r,$domain,$lonhost,$username,$domdesc) = @_; |
my ($retrieved,$output,$upass) = &process_credentials($env{'form.logtoken'}, |
my ($retrieved,$output,$upass) = &process_credentials($env{'form.logtoken'}, |
Line 808 sub create_account {
|
Line 852 sub create_account {
|
|
|
sub username_validation { |
sub username_validation { |
my ($r,$username,$domain,$domdesc,$contact_name,$contact_email,$courseid, |
my ($r,$username,$domain,$domdesc,$contact_name,$contact_email,$courseid, |
$lonhost) = @_; |
$lonhost,$statustocreate) = @_; |
my ($retrieved,$output,$upass); |
my ($retrieved,$output,$upass); |
|
|
$username= &LONCAPA::clean_username($username); |
$username= &LONCAPA::clean_username($username); |
Line 824 sub username_validation {
|
Line 868 sub username_validation {
|
my $result = &Apache::lonnet::authenticate($username,$upass,$domain); |
my $result = &Apache::lonnet::authenticate($username,$upass,$domain); |
if ($result ne 'no_host') { |
if ($result ne 'no_host') { |
my %form = &start_session($r,$username,$domain,$lonhost,$courseid); |
my %form = &start_session($r,$username,$domain,$lonhost,$courseid); |
$output = '<br /><br />'.&mt('A GCI WebCenter account already exists for username [_1].','<tt>'.$username.'</tt>').'<br />'.&mt('The password entered was also correct so you have been logged in.'); |
$output = '<br /><br />'.&mt('A LON-CAPA account already exists for username [_1] at this institution ([_2]).','<tt>'.$username.'</tt>',$domdesc).'<br />'.&mt('The password entered was also correct so you have been logged in.'); |
return ('existingaccount',$output); |
return ('existingaccount',$output); |
} else { |
} else { |
$output = &login_failure_msg($courseid); |
$output = &login_failure_msg($courseid); |
Line 842 sub username_validation {
|
Line 886 sub username_validation {
|
} |
} |
if ($authok eq 'authorized') { |
if ($authok eq 'authorized') { |
$output = &username_check($username,$domain,$domdesc,$courseid,$lonhost, |
$output = &username_check($username,$domain,$domdesc,$courseid,$lonhost, |
$contact_email,$contact_name); |
$contact_email,$contact_name,undef, |
|
$statustocreate); |
} else { |
} else { |
$output = &login_failure_msg($courseid); |
$output = &login_failure_msg($courseid); |
} |
} |
Line 867 sub login_failure_msg {
|
Line 912 sub login_failure_msg {
|
} |
} |
|
|
sub username_check { |
sub username_check { |
my ($username,$domain,$domdesc,$courseid,$lonhost,$contact_email,$contact_name, |
my ($username,$domain,$domdesc,$courseid,$lonhost,$contact_email, |
$sso_logout) = @_; |
$contact_name,$sso_logout,$statustocreate) = @_; |
my (%rulematch,%inst_results,$checkfail,$rowcount,$editable,$output,$msg, |
my (%rulematch,%inst_results,$checkfail,$rowcount,$editable,$output,$msg, |
%alerts,%curr_rules,%got_rules); |
%alerts,%curr_rules,%got_rules); |
&call_rulecheck($username,$domain,\%alerts,\%rulematch, |
&call_rulecheck($username,$domain,\%alerts,\%rulematch, |
\%inst_results,\%curr_rules,%got_rules,'username'); |
\%inst_results,\%curr_rules,\%got_rules,'username'); |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if ($alerts{'username'}{$domain}{$username}) { |
if ($alerts{'username'}{$domain}{$username}) { |
Line 888 sub username_check {
|
Line 933 sub username_check {
|
} |
} |
} |
} |
if (!$checkfail) { |
if (!$checkfail) { |
|
if (ref($statustocreate) eq 'ARRAY') { |
|
$checkfail = 'inststatus'; |
|
if (ref($inst_results{$username.':'.$domain}{inststatus}) eq 'ARRAY') { |
|
foreach my $inststatus (@{$inst_results{$username.':'.$domain}{inststatus}}) { |
|
if (grep(/^\Q$inststatus\E$/,@{$statustocreate})) { |
|
undef($checkfail); |
|
last; |
|
} |
|
} |
|
} elsif (grep(/^default$/,@{$statustocreate})) { |
|
undef($checkfail); |
|
} |
|
} |
|
} |
|
if (!$checkfail) { |
$output = '<form method="post" action="/adm/createaccount">'; |
$output = '<form method="post" action="/adm/createaccount">'; |
(my $datatable,$rowcount,$editable) = |
(my $datatable,$rowcount,$editable) = |
&Apache::loncreateuser::personal_data_display($username,$domain,1,'selfcreate', |
&Apache::loncreateuser::personal_data_display($username,$domain,1,'selfcreate', |
Line 922 sub username_check {
|
Line 982 sub username_check {
|
} elsif ($checkfail eq 'authtoken') { |
} elsif ($checkfail eq 'authtoken') { |
$msg .= '<span class="LC_error">'.&mt('Error creating token.').'</span>'. |
$msg .= '<span class="LC_error">'.&mt('Error creating token.').'</span>'. |
'<br />'.$output; |
'<br />'.$output; |
|
} elsif ($checkfail eq 'inststatus') { |
|
$msg .= '<span class="LC_warning">'. |
|
&mt('You are not permitted to create a LON-CAPA account.'). |
|
'</span><br /><br />'.$output; |
} |
} |
$msg .= &mt('Please contact the [_1] ([_2]) for assistance.', |
$msg .= &mt('Please contact the [_1] ([_2]) for assistance.', |
$contact_name,$contact_email).'<br /><hr />'. |
$contact_name,$contact_email).'<br /><hr />'. |
Line 1000 sub username_activation {
|
Line 1064 sub username_activation {
|
# Call modifyuser |
# Call modifyuser |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts,%info); |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts,%info); |
&call_rulecheck($username,$domain,\%alerts,\%rulematch, |
&call_rulecheck($username,$domain,\%alerts,\%rulematch, |
\%inst_results,\%curr_rules,%got_rules); |
\%inst_results,\%curr_rules,\%got_rules); |
my @userinfo = ('firstname','middlename','lastname','generation', |
my @userinfo = ('firstname','middlename','lastname','generation', |
'permanentemail','id'); |
'permanentemail','id'); |
my %canmodify = |
my %canmodify = |
Line 1105 sub linkto_email_help {
|
Line 1169 sub linkto_email_help {
|
return $msg; |
return $msg; |
} |
} |
|
|
sub create_recaptcha { |
sub create_captcha { |
my $captcha = Captcha::reCAPTCHA->new; |
my ($output_dir,$db_dir) = @_; |
return $captcha->get_options_setter({theme => 'white'})."\n". |
my %captcha_params = &captcha_settings(); |
$captcha->get_html('PUBLICKEY'); # generate public key for IP |
my ($output,$maxtries,$tries) = ('',10,0); |
# from http://recaptcha.net/ |
while ($tries < $maxtries) { |
|
$tries ++; |
|
my $captcha = Authen::Captcha->new ( |
|
output_folder => $captcha_params{'output_dir'}, |
|
data_folder => $captcha_params{'db_dir'}, |
|
); |
|
my $md5sum = $captcha->generate_code($captcha_params{'numchars'}); |
|
|
|
if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { |
|
$output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". |
|
&mt('Type in the letters/numbers shown below').' '. |
|
'<input type="text" size="5" name="code" value="" /><br />'. |
|
'<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" />'; |
|
last; |
|
} |
|
} |
|
return $output; |
|
} |
|
|
|
sub captcha_settings { |
|
my %captcha_params = ( |
|
output_dir => $Apache::lonnet::perlvar{'lonCaptchaDir'}, |
|
www_output_dir => "/captchaspool", |
|
db_dir => $Apache::lonnet::perlvar{'lonCaptchaDb'}, |
|
numchars => '5', |
|
); |
|
return %captcha_params; |
} |
} |
|
|
sub getkeys { |
sub getkeys { |