version 1.73, 2017/07/26 19:45:45
|
version 1.90, 2025/02/18 17:45:11
|
Line 94 sub handler {
|
Line 94 sub handler {
|
my $lonhost = $r->dir_config('lonHostID'); |
my $lonhost = $r->dir_config('lonHostID'); |
my $include = $r->dir_config('lonIncludes'); |
my $include = $r->dir_config('lonIncludes'); |
my $start_page; |
my $start_page; |
|
my $args = {}; |
|
|
|
(undef,undef,undef,my $clientmathml,my $clientunicode) = |
|
&Apache::loncommon::decode_user_agent(); |
|
if ($clientunicode && !$clientmathml) { |
|
$args->{'browser.unicode'} = 1; |
|
} |
my $handle = &Apache::lonnet::check_for_valid_session($r); |
my $handle = &Apache::lonnet::check_for_valid_session($r); |
if (($handle ne '') && ($handle !~ /^publicuser_\d+$/)) { |
if (($handle ne '') && ($handle !~ /^publicuser_\d+$/)) { |
$start_page = |
$start_page = |
&Apache::loncommon::start_page('Already logged in'); |
&Apache::loncommon::start_page('Already logged in',undef,$args); |
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".'<div class="LC_landmark" role="main">'. |
|
'<h2 class="LC_heading_2">'.&mt('You are already logged in').'</h2>'. |
'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].', |
'<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>'). |
'<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></div>'.$end_page); |
return OK; |
return OK; |
} |
} |
|
|
Line 139 sub handler {
|
Line 146 sub handler {
|
&print_footer($r); |
&print_footer($r); |
return OK; |
return OK; |
} else { |
} else { |
$start_page = &Apache::loncommon::start_page($title,$js); |
$start_page = &Apache::loncommon::start_page($title,$js,$args); |
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 150 sub handler {
|
Line 157 sub handler {
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
my ($cancreate,$statustocreate,$statusforemail,$emailusername, |
my ($cancreate,$statustocreate,$statusforemail,$emailusername, |
$verification,$emaildomain,$types,$usertypes,$othertitle) = |
$emailoptions,$verification,$emaildomain,$types,$usertypes,$othertitle) = |
&get_creation_controls($domain,$domconfig{'usercreation'}); |
&get_creation_controls($domain,$domconfig{'usercreation'}); |
my ($additems,$pagetitle); |
my ($pagetitle,$need_affiliation); |
if (ref($cancreate) eq 'ARRAY') { |
if (ref($cancreate) eq 'ARRAY') { |
unless (($env{'form.token'}) || ($sso_username ne '') || ($env{'form.phase'}) || |
unless (($env{'form.token'}) || ($sso_username ne '') || ($env{'form.phase'}) || |
($env{'form.create_with_email'})) { |
($env{'form.create_with_email'})) { |
if ((grep(/^email$/,@{$cancreate})) && (ref($statusforemail) eq 'ARRAY')) { |
if ((grep(/^email$/,@{$cancreate})) && (ref($statusforemail) eq 'ARRAY')) { |
my $usertype = &get_usertype($domain); |
my $usertype = &get_usertype($domain); |
if (($usertype ne '') && (grep(/^\Q$usertype\E$/,@{$statusforemail}))) { |
if ((($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) && |
$js .= &username_js(); |
(@{$statusforemail} > 0)) { |
} elsif (($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) { |
|
$js .= &setelements_js($statusforemail,$types,$usertypes,$othertitle); |
$js .= &setelements_js($statusforemail,$types,$usertypes,$othertitle); |
$additems = {'add_entries' => { 'onload' => "setElements();"} }; |
$args->{'add_entries'} = { 'onload' => "setElements();"}; |
if (@{$cancreate} == 1) { |
if ((@{$cancreate} == 1) && (@{$statusforemail} > 0)) { |
$pagetitle = 'Select affiliation'; |
$pagetitle = 'Select affiliation'; |
} |
} |
|
$need_affiliation = 1; |
|
} else { |
|
$js .= &username_js(); |
} |
} |
} |
} |
} |
} |
} |
} |
$start_page = &Apache::loncommon::start_page($title,$js,$additems); |
$start_page = &Apache::loncommon::start_page($title,$js,$args); |
if (@{$cancreate} == 0) { |
if (@{$cancreate} == 0) { |
&print_header($r,$start_page,$courseid,$pagetitle); |
&print_header($r,$start_page,$courseid,$pagetitle); |
my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
my $output = '<h2 class="LC_heading_2">'.&mt('Account creation unavailable').'</h2>'. |
'<span class="LC_warning">'. |
'<span class="LC_warning">'. |
&mt('Creation of a new user account using an institutional log-in ID or e-mail verification is not permitted for: [_1].',$domdesc). |
&mt('Creation of a new user account using an institutional log-in ID or e-mail verification is not permitted for: [_1].',$domdesc). |
'</span><br /><br />'; |
'</span><br /><br />'; |
Line 187 sub handler {
|
Line 196 sub handler {
|
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 = '<h2 class="LC_heading_2">'.&mt('Account creation').'</h2>'. |
&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 />'; |
my $shibenv; |
my $shibenv; |
if (($r->dir_config('lonOtherAuthen') eq 'yes') && |
if (($r->dir_config('lonOtherAuthen') eq 'yes') && |
Line 221 sub handler {
|
Line 230 sub handler {
|
$lonhost,$contact_email,$contact_name, |
$lonhost,$contact_email,$contact_name, |
$sso_logout,$statustocreate,$shibenv); |
$sso_logout,$statustocreate,$shibenv); |
} else { |
} else { |
$msg = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
$msg = '<h2 class="LC_heading_2">'.&mt('Account creation unavailable').'</h2>'. |
'<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 />'. |
$sso_logout; |
$sso_logout; |
} |
} |
Line 255 sub handler {
|
Line 264 sub handler {
|
return OK; |
return OK; |
} |
} |
} |
} |
my ($usernameset,$condition); |
my ($usernameset,$condition,$excluded,$hascustom); |
if ((grep(/^email$/,@{$cancreate})) && (($env{'form.create_with_email'}) || |
if ((grep(/^email$/,@{$cancreate})) && (($env{'form.create_with_email'}) || |
((!$token) && ($env{'form.phase'} eq '')))) { |
((!$token) && ($env{'form.phase'} eq '')))) { |
my $usertype = &get_usertype($domain); |
my $usertype = &get_usertype($domain); |
|
if ($usertype eq '') { |
|
$usertype = 'default'; |
|
} |
if (ref($verification) eq 'HASH') { |
if (ref($verification) eq 'HASH') { |
if ($verification->{$usertype} eq 'other') { |
if ($verification->{$usertype} =~ /^(free|first)$/) { |
$usernameset = 1; |
$usernameset = $verification->{$usertype}; |
|
} |
|
} |
|
if (ref($emailoptions) eq 'HASH') { |
|
if ($emailoptions->{$usertype} =~ /^(inst|noninst)$/) { |
|
my $chosen = $1; |
if (ref($emaildomain) eq 'HASH') { |
if (ref($emaildomain) eq 'HASH') { |
if ($emaildomain->{$usertype} ne '') { |
if (ref($emaildomain->{$usertype}) eq 'HASH') { |
$condition = $emaildomain->{$usertype}; |
if ($chosen eq 'inst') { |
|
$condition = $emaildomain->{$usertype}->{$chosen}; |
|
} else { |
|
$excluded = $emaildomain->{$usertype}->{$chosen}; |
|
} |
} |
} |
} |
} |
|
} elsif ($emailoptions->{$usertype} eq 'custom') { |
|
$hascustom = 1; |
} |
} |
} |
} |
} |
} |
Line 301 sub handler {
|
Line 324 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); |
my $usertype = &get_usertype($domain); |
my $usertype = &get_usertype($domain); |
|
if ($usertype eq '') { |
|
$usertype = 'default'; |
|
} |
$output = &process_email_request($env{'form.uname'},$domain,$domdesc, |
$output = &process_email_request($env{'form.uname'},$domain,$domdesc, |
$contact_name,$contact_email,$cancreate, |
$contact_name,$contact_email,$cancreate, |
$lonhost,$domconfig{'usercreation'}, |
$lonhost,$domconfig{'usercreation'}, |
$emailusername,$courseid,$usertype, |
$emailusername,$courseid,$usertype, |
$usernameset,$condition); |
$usernameset,$condition,$excluded,$hascustom); |
} elsif (!$token) { |
} elsif (!$token) { |
&print_header($r,$start_page,$courseid,$pagetitle); |
&print_header($r,$start_page,$courseid,$pagetitle); |
my $now=time; |
my $now=time; |
if ((grep(/^login$/,@{$cancreate})) && (!grep(/^email$/,@{$cancreate}))) { |
if ((grep(/^login$/,@{$cancreate})) && |
if (open(my $jsh,"<$include/londes.js")) { |
((!grep(/^email$/,@{$cancreate})) || ($need_affiliation))) { |
|
if (open(my $jsh,"<","$include/londes.js")) { |
while(my $line = <$jsh>) { |
while(my $line = <$jsh>) { |
$r->print($line); |
$r->print($line); |
} |
} |
Line 319 sub handler {
|
Line 346 sub handler {
|
} |
} |
} |
} |
if (grep(/^email$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
$r->print(&javascript_validmail()); |
$r->print(&javascript_validmail($condition)); |
} |
} |
my $usertype = &get_usertype($domain); |
my $usertype = &get_usertype($domain); |
$output = &print_username_form($r,$domain,$domdesc,$cancreate,$now,$lonhost, |
$output = &print_username_form($r,$domain,$domdesc,$cancreate,$now,$lonhost, |
$include,$courseid,$emailusername, |
$include,$courseid,$emailusername, |
$statusforemail,$usernameset,$condition, |
$statusforemail,$usernameset,$condition, |
$usertype,$types,$usertypes,$othertitle); |
$excluded,$usertype,$types,$usertypes,$othertitle); |
} |
} |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 409 sub selfenroll_crumbs {
|
Line 436 sub selfenroll_crumbs {
|
} |
} |
|
|
sub javascript_setforms { |
sub javascript_setforms { |
my ($now,$emailusername,$captcha,$usertype,$recaptchaversion,$usernameset,$condition) = @_; |
my ($now,$emailusername,$captcha,$usertype,$recaptchaversion,$usernameset,$condition,$excluded) = @_; |
my ($setuserinfo,@required,$requiredchk); |
my ($setuserinfo,@required,$requiredchk); |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
Line 419 sub javascript_setforms {
|
Line 446 sub javascript_setforms {
|
} |
} |
$setuserinfo .= ' server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n"; |
$setuserinfo .= ' server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n"; |
} |
} |
$setuserinfo .= ' server.elements.type.value=client.elements.type.value;'."\n"; |
if ($usertype ne '') { |
|
$setuserinfo .= ' server.elements.type.value=client.elements.type.value;'."\n"; |
|
} |
} |
} |
if ($captcha eq 'original') { |
if ($captcha eq 'original') { |
$setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". |
$setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". |
Line 431 sub javascript_setforms {
|
Line 460 sub javascript_setforms {
|
' server.elements.recaptcha_response_field.value=client.elements.recaptcha_response_field.value;'."\n"; |
' server.elements.recaptcha_response_field.value=client.elements.recaptcha_response_field.value;'."\n"; |
} |
} |
} |
} |
if ($usernameset) { |
if ($usernameset eq 'free') { |
$setuserinfo .= |
$setuserinfo .= |
' server.elements.username.value=client.elements.username.value;'."\n"; |
' server.elements.username.value=client.elements.username.value;'."\n"; |
} |
} |
Line 478 $requiredchk
|
Line 507 $requiredchk
|
uextkey=client.elements.uextkey.value; |
uextkey=client.elements.uextkey.value; |
lextkey=client.elements.lextkey.value; |
lextkey=client.elements.lextkey.value; |
initkeys(); |
initkeys(); |
|
|
server.elements.upass.value |
server.elements.upass.value |
= getCrypted(client.elements.upass$now.value); |
= getCrypted(client.elements.upass$now.value); |
|
|
client.elements.uname.value=''; |
client.elements.uname.value=''; |
client.elements.upass$now.value=''; |
client.elements.upass$now.value=''; |
if (context == 'email') { |
if (context == 'email') { |
Line 504 ENDSCRIPT
|
Line 531 ENDSCRIPT
|
} |
} |
|
|
sub javascript_checkpass { |
sub javascript_checkpass { |
my ($now,$context) = @_; |
my ($now,$context,$domain) = @_; |
my $nopass = &mt('You must enter a password.'); |
my $nopass = &mt('You must enter a password.'); |
my $mismatchpass = &mt('The passwords you entered did not match.')."\n". |
my $mismatchpass = &mt('The passwords you entered did not match.')."\n". |
&mt('Please try again.'); |
&mt('Please try again.'); |
|
my ($numrules,$intargjs) = |
|
&Apache::loncommon::passwd_validation_js('upass',$domain); |
&js_escape(\$nopass); |
&js_escape(\$nopass); |
&js_escape(\$mismatchpass); |
&js_escape(\$mismatchpass); |
my $js = <<"ENDSCRIPT"; |
my $js = <<"ENDSCRIPT"; |
Line 524 sub javascript_checkpass {
|
Line 553 sub javascript_checkpass {
|
return false; |
return false; |
} |
} |
if (upass == upasscheck) { |
if (upass == upasscheck) { |
|
var numrules = $numrules; |
|
if (numrules > 0) { |
|
$intargjs |
|
} |
client.elements.upasscheck$now.value=''; |
client.elements.upasscheck$now.value=''; |
if (validate_email(client)) { |
if (validate_email(client)) { |
send(one,two,'$context'); |
send(one,two,'$context'); |
Line 543 ENDSCRIPT
|
Line 576 ENDSCRIPT
|
} |
} |
|
|
sub javascript_validmail { |
sub javascript_validmail { |
|
my ($condition) = @_; |
my %js_lt = &Apache::lonlocal::texthash ( |
my %js_lt = &Apache::lonlocal::texthash ( |
email => 'The e-mail address you entered', |
email => 'The e-mail address you entered', |
notv => 'is not a valid e-mail address', |
notv => 'is not a valid e-mail address', |
|
avae => 'A valid e-mail address is not formed when the value you entered is combined with the required domain', |
); |
); |
my $output = "\n".'<script type="text/javascript">'."\n". |
my $output = "\n".'<script type="text/javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
Line 554 sub javascript_validmail {
|
Line 589 sub javascript_validmail {
|
$output .= <<"ENDSCRIPT"; |
$output .= <<"ENDSCRIPT"; |
function validate_email(client) { |
function validate_email(client) { |
field = client.uname; |
field = client.uname; |
if (validmail(field) == false) { |
var condition = '$condition'; |
alert("$js_lt{'email'}: "+field.value+" $js_lt{'notv'}."); |
if (validmail(field,condition) == false) { |
|
if ((condition != undefined) && (condition != '')) { |
|
alert("$js_lt{'avae'}: "+condition); |
|
} else { |
|
alert("$js_lt{'email'}: "+field.value+" $js_lt{'notv'}."); |
|
} |
return false; |
return false; |
} |
} |
return true; |
return true; |
Line 567 ENDSCRIPT
|
Line 607 ENDSCRIPT
|
|
|
sub print_username_form { |
sub print_username_form { |
my ($r,$domain,$domdesc,$cancreate,$now,$lonhost,$include,$courseid,$emailusername, |
my ($r,$domain,$domdesc,$cancreate,$now,$lonhost,$include,$courseid,$emailusername, |
$statusforemail,$usernameset,$condition,$usertype,$types,$usertypes, |
$statusforemail,$usernameset,$condition,$excluded,$usertype,$types,$usertypes, |
$othertitle) = @_; |
$othertitle) = @_; |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
crac => 'Create account with a username provided by this institution', |
crac => 'Create account with a username provided by this institution', |
Line 583 sub print_username_form {
|
Line 623 sub print_username_form {
|
if (grep(/^login$/,@{$cancreate})) { |
if (grep(/^login$/,@{$cancreate})) { |
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) { |
if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) { |
$output = '<div class="LC_left_float"><h3>'.$lt{'crac'}.'</h3>'; |
$output = '<div class="LC_left_float"><h2 class="LC_heading_2">'.$lt{'crac'}.'</h2>'; |
$output .= &mt('If you already have a log-in ID at this institution [_1]you may be able to use it for LON-CAPA.','<br />'). |
$output .= &mt('If you already have a log-in ID at this institution [_1]you may be able to use it for LON-CAPA.','<br />'). |
'<br /><br />'. |
'<br /><br />'. |
$lt{'type'}. |
$lt{'type'}. |
Line 593 sub print_username_form {
|
Line 633 sub print_username_form {
|
} |
} |
} |
} |
if (grep(/^email$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
$output .= '<div class="LC_left_float"><h3>'.$lt{'crae'}.'</h3>'; |
$output .= '<div class="LC_left_float"><h2 class="LC_heading_2">'.$lt{'crae'}.'</h2>'; |
if ($usertype ne '') { |
if ($usertype ne '') { |
if (ref($statusforemail) eq 'ARRAY') { |
if ((ref($statusforemail) eq 'ARRAY') && (@{$statusforemail} > 0)) { |
unless (grep(/^\Q$usertype\E$/,@{$statusforemail})) { |
unless (grep(/^\Q$usertype\E$/,@{$statusforemail})) { |
undef($usertype); |
undef($usertype); |
} |
} |
|
} elsif ($usertype ne 'default') { |
|
undef($usertype); |
} |
} |
} |
} |
if (($usertype eq '') && (ref($statusforemail) eq 'ARRAY') && |
if (($usertype eq '') && (ref($statusforemail) eq 'ARRAY') && |
(@{$statusforemail}) && (ref($types) eq 'ARRAY')) { |
(@{$statusforemail} > 0) && (ref($types) eq 'ARRAY') && (@{$types} > 0)) { |
my @posstypes = @{$types}; |
my @posstypes = @{$types}; |
unless (grep(/^default$/,@posstypes)) { |
unless (grep(/^default$/,@posstypes)) { |
push(@posstypes,'default'); |
push(@posstypes,'default'); |
} |
} |
$output .= '<p>'.&mt('Choose your affiliation at [_1]',$domdesc).'</p>'."\n". |
$output .= '<form name="reportstatus" id="LC_reportstatus" action="/adm/createaccount" method="post" '. |
'<form name="reportstatus" id="LC_reportstatus" action="" method="post" '. |
'onsubmit="return checkVerification();"><fieldset><legend>'. |
'onsubmit="return checkVerification();"><p>'; |
&mt('Choose your affiliation at [_1]',$domdesc).'</legend>'; |
foreach my $type (@posstypes) { |
foreach my $type (@posstypes) { |
my $name; |
my $name; |
if ($type eq 'default') { |
if ($type eq 'default') { |
Line 622 sub print_username_form {
|
Line 664 sub print_username_form {
|
} |
} |
} |
} |
} |
} |
$output .= '<label><input type="radio" name="type" value="'.$type.'" />'. |
my $checked; |
|
if ($env{'form.type'} eq $type) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$output .= '<label><input type="radio" name="type" value="'.$type.'"'.$checked.' />'. |
$name.'</label>'.(' 'x2); |
$name.'</label>'.(' 'x2); |
} |
} |
if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { |
if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { |
$output .= "\n".'<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />'; |
$output .= "\n".'<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />'; |
} |
} |
$output .= '</p>'."\n".'<p><input type="submit" name="reportedtype" value="'.&mt('Submit').'" /></p></form>'; |
$output .= "\n".'<p><input type="submit" name="reportedtype" value="'.&mt('Submit').'" />'. |
|
'</p></fieldset></form>'."\n"; |
} else { |
} else { |
my ($captchaform,$error,$captcha,$recaptchaversion) = |
my ($captchaform,$error,$captcha,$recaptchaversion) = |
&Apache::loncommon::captcha_display('usercreation',$lonhost); |
&Apache::loncommon::captcha_display('usercreation',$lonhost); |
Line 659 sub print_username_form {
|
Line 706 sub print_username_form {
|
$output .= $prompt.'<br />'. |
$output .= $prompt.'<br />'. |
$lt{'yopw'}.'<br />'; |
$lt{'yopw'}.'<br />'; |
} |
} |
|
if ($usertype eq '') { |
|
$usertype = 'default'; |
|
} elsif (ref($usertypes) eq 'HASH') { |
|
my $usertitle; |
|
if ($usertype eq 'default') { |
|
$usertitle = $othertitle; |
|
} elsif (exists($usertypes->{$usertype})) { |
|
$usertitle = $usertypes->{$usertype}; |
|
} |
|
if ($usertitle ne '') { |
|
$output .= &mt('Self-reported affiliation: [_1]', |
|
'<span style="font-style: italic;">'.$usertitle.'</span>'). |
|
'<br />'; |
|
} |
|
} |
$output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform, |
$output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform, |
$courseid,$emailusername,$captcha,$usertype, |
$courseid,$emailusername,$captcha,$usertype, |
$recaptchaversion,$usernameset,$condition); |
$recaptchaversion,$usernameset,$condition,$excluded); |
} |
} |
} |
} |
$output .= '</div>'; |
$output .= '</div>'; |
Line 687 sub login_box {
|
Line 749 sub login_box {
|
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', |
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', |
$lonhost); |
$lonhost); |
$output = &serverform($logtoken,$lonhost,undef,$courseid,$context); |
$output = &serverform($logtoken,$lonhost,undef,$courseid,$context); |
my $unameform = '<input type="text" name="uname" size="20" value="" autocomplete="off" />'; |
my $unameform = '<input type="text" name="uname" id="uname" size="20" value="" autocomplete="off" />'; |
my $upassform = '<input type="password" name="upass'.$now.'" size="20" autocomplete="off" />'; |
my $upassform = '<input type="password" name="upass'.$now.'" id="upass'.$now.'" size="20" autocomplete="new-password" />'; |
$output .= '<form name="client" method="post" action="" onsubmit="return(send('."'server','client'".'));">'."\n". |
$output .= '<form name="client" method="post" action="" onsubmit="return(send('."'server','client'".'));">'."\n". |
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::row_title($titles{$context}, |
&Apache::lonhtmlcommon::row_title('<label for="uname">'.$titles{$context}.'</label>', |
'LC_pick_box_title')."\n". |
'LC_pick_box_title')."\n". |
$unameform."\n". |
$unameform."\n". |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_title(&mt('Password'), |
&Apache::lonhtmlcommon::row_title('<label for="upass'.$now.'">'.&mt('Password').'</label>', |
'LC_pick_box_title')."\n". |
'LC_pick_box_title')."\n". |
$upassform; |
$upassform; |
if ($context eq 'selfenroll') { |
if ($context eq 'selfenroll') { |
Line 709 sub login_box {
|
Line 771 sub login_box {
|
$output .= '<input type="hidden" name="udom" value="'.$domain.'" />'; |
$output .= '<input type="hidden" name="udom" value="'.$domain.'" />'; |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(1). |
$output .= &Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(). |
&Apache::lonhtmlcommon::row_title('<span class="LC_visually_hidden">'. |
|
&mt('Submit').'</span>','','','',1). |
'<br /><input type="submit" name="username_validation" value="'. |
'<br /><input type="submit" name="username_validation" value="'. |
$submit_text.'" />'."\n"; |
$submit_text.'" />'."\n"; |
if ($context eq 'selfenroll') { |
if ($context eq 'selfenroll') { |
Line 729 sub login_box {
|
Line 792 sub login_box {
|
sub process_email_request { |
sub process_email_request { |
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate, |
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate, |
$server,$settings,$emailusername,$courseid,$usertype,$usernameset, |
$server,$settings,$emailusername,$courseid,$usertype,$usernameset, |
$condition) = @_; |
$condition,$excluded,$hascustom) = @_; |
my ($output,$uname); |
my ($output,$uname); |
if (ref($cancreate) eq 'ARRAY') { |
if (ref($cancreate) eq 'ARRAY') { |
if (!grep(/^email$/,@{$cancreate})) { |
if (!grep(/^email$/,@{$cancreate})) { |
$output = &invalid_state('noemails',$domdesc, |
$output = &invalid_state('noemails',$domdesc, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
return $output; |
return $output; |
} elsif ($useremail !~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) { |
} elsif ((($condition ne '') && ($useremail !~ /^[^\@]+$/)) || |
|
(($condition eq '') && ($useremail !~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/))) { |
$output = &invalid_state('baduseremail',$domdesc, |
$output = &invalid_state('baduseremail',$domdesc, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
return $output; |
return $output; |
} else { |
} else { |
$useremail =~ s/^\s+|\s+$//g; |
$useremail =~ s/^\s+|\s+$//g; |
my $possuname; |
my $possuname; |
if ($env{'form.username'}) { |
if ($condition ne '') { |
|
if ($usernameset eq 'first') { |
|
$possuname = $useremail; |
|
} |
|
$useremail .= $condition; |
|
} elsif ($excluded ne '') { |
|
if ($useremail =~ /^[^\@]+\Q$excluded\E$/) { |
|
$output = &invalid_state('userrules',$domdesc, |
|
$contact_name,$contact_email); |
|
return $output; |
|
} |
|
} |
|
if (($usernameset eq 'free') && ($env{'form.username'} ne '')) { |
$possuname = $env{'form.username'}; |
$possuname = $env{'form.username'}; |
$possuname =~ s/^\s+|\s+$//g; |
} elsif (($usernameset eq 'first') && ($condition eq '')) { |
|
if ($condition eq '') { |
|
($possuname) = ($useremail =~ /^([^\@]+)\@/); |
|
} |
} |
} |
if (($usernameset) && ($possuname ne '')) { |
if ($possuname ne '') { |
if ($condition ne '') { |
$possuname =~ s/^\s+|\s+$//g; |
if ($useremail =~ /\Q$condition\E/) { |
if ($possuname ne '') { |
$uname = &LONCAPA::clean_username($possuname); |
$uname=&LONCAPA::clean_username($possuname); |
} else { |
if ($uname ne $possuname) { |
$output = &invalid_state('emailfail',$domdesc, |
$output = &invalid_state('badusername',$domdesc, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
return $output; |
return $output; |
} |
} |
} else { |
|
$uname=&LONCAPA::clean_username($possuname); |
|
} |
|
if ($uname ne $possuname) { |
|
$output = &invalid_state('badusername',$domdesc, |
|
$contact_name,$contact_email); |
|
return $output; |
|
} |
} |
} else { |
} |
|
if ($possuname eq '') { |
$uname=&LONCAPA::clean_username($useremail); |
$uname=&LONCAPA::clean_username($useremail); |
if ($useremail ne $uname) { |
if ($useremail ne $uname) { |
$output = &invalid_state('badusername',$domdesc, |
$output = &invalid_state('badusername',$domdesc, |
Line 780 sub process_email_request {
|
Line 853 sub process_email_request {
|
} else { |
} else { |
my ($captcha_chk,$captcha_error) = &Apache::loncommon::captcha_response('usercreation',$server); |
my ($captcha_chk,$captcha_error) = &Apache::loncommon::captcha_response('usercreation',$server); |
if ($captcha_chk != 1) { |
if ($captcha_chk != 1) { |
$output = &invalid_state('captcha',$domdesc,$contact_name, |
$output = '<span class="LC_warning">'. |
$contact_email,$captcha_error); |
&mt('Validation of the code you entered failed.').'</span>'. |
|
'<br />'.$captcha_error."\n".'<br /><p>'. |
|
&mt('[_1]Return[_2] to the previous page to try again.', |
|
'<a href="javascript:document.retryemail.submit();">','</a>')."\n". |
|
'<form name="retryemail" action="/adm/createaccount" method="post" />'. |
|
'<input type="hidden" name="domain" value="'.$domain.'" />'."\n"; |
|
if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { |
|
$output .= '<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />'."\n"; |
|
} |
|
if ($env{'form.type'}) { |
|
my $usertype = &get_usertype($domain); |
|
if ($usertype ne '') { |
|
$output .= '<input type="hidden" name="type" value="'.$usertype.'" />'."\n". |
|
'<input type="hidden" name="reportedtype" value="'.&mt('Submit').'" />'."\n"; |
|
} |
|
} |
|
$output .= '</form></p>'; |
return $output; |
return $output; |
} |
} |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); |
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); |
Line 796 sub process_email_request {
|
Line 885 sub process_email_request {
|
} |
} |
} |
} |
} |
} |
if (($usernameset) && ($possuname ne '')) { |
if ($hascustom) { |
my $format_msg = |
my $format_msg = |
&guest_format_check($useremail,$domain,$cancreate, |
&guest_format_check($useremail,$domain,$cancreate, |
$settings); |
$settings,$usertype); |
if ($format_msg) { |
if ($format_msg) { |
$output = &invalid_state('userformat',$domdesc,$contact_name, |
$output = &invalid_state('userformat',$domdesc,$contact_name, |
$contact_email,$format_msg); |
$contact_email,$format_msg); |
Line 812 sub process_email_request {
|
Line 901 sub process_email_request {
|
$contact_email,$courseid,$emailusername,$usertype, |
$contact_email,$courseid,$emailusername,$usertype, |
$uname); |
$uname); |
} |
} |
return $output; |
return '<div class="LC_landmark" role="main">'.$output.'</div>'; |
} |
} |
|
|
sub call_rulecheck { |
sub call_rulecheck { |
Line 832 sub call_rulecheck {
|
Line 921 sub call_rulecheck {
|
sub send_token { |
sub send_token { |
my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername, |
my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername, |
$usertype,$uname) = @_; |
$usertype,$uname) = @_; |
my $msg = '<h3>'.&mt('Account creation status').'</h3>'. |
my $msg = '<h2 class="LC_heading_2">'.&mt('Account creation status').'</h2>'. |
&mt('Thank you for your request to create a new LON-CAPA account.'). |
&mt('Thank you for your request to create a new LON-CAPA account.'). |
'<br /><br />'; |
'<br /><br />'; |
my $now = time; |
my $now = time; |
$env{'form.logtoken'} =~ s/(`)//g; |
$env{'form.logtoken'} =~ s/(`)//g; |
if ($env{'form.logtoken'}) { |
if ($env{'form.logtoken'}) { |
my $logtoken = $env{'form.logtoken'}; |
my $logtoken = $env{'form.logtoken'}; |
|
my $earlyout; |
my $tmpinfo=Apache::lonnet::reply('tmpget:'.$logtoken,$server); |
my $tmpinfo=Apache::lonnet::reply('tmpget:'.$logtoken,$server); |
if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) { |
if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) { |
$msg = &mt('Information needed to process your request is missing, inaccessible or expired.') |
$msg = &mt('Information needed to process your request is missing, inaccessible or expired.') |
.'<br />'.&mt('Return to the previous page to try again.'); |
.'<br /><p>'.&mt('[_1]Return[_2] to the previous page to try again.', |
|
'<a href="javascript:document.retryemail.submit();">','</a>'); |
|
$earlyout = 1; |
} else { |
} else { |
my $reply = &Apache::lonnet::reply('tmpdel:'.$logtoken,$server); |
my $reply = &Apache::lonnet::reply('tmpdel:'.$logtoken,$server); |
unless ($reply eq 'ok') { |
unless ($reply eq 'ok') { |
$msg .= &mt('Request could not be processed.'); |
$msg .= &mt('Request could not be processed.'); |
} |
} |
} |
} |
my %info = ('ip' => $ENV{'REMOTE_ADDR'}, |
# Check if the password entered by the user satisfies domain's requirements |
|
my %passwdconf = &Apache::lonnet::get_passwdconf($domain); |
|
my ($min,$max,@chars); |
|
$min = $Apache::lonnet::passwdmin; |
|
if (ref($passwdconf{'chars'}) eq 'ARRAY') { |
|
if ($passwdconf{'min'} =~ /^\d+$/) { |
|
if ($passwdconf{'min'} > $min) { |
|
$min = $passwdconf{'min'}; |
|
} |
|
} |
|
if ($passwdconf{'max'} =~ /^\d+$/) { |
|
$max = $passwdconf{'max'}; |
|
} |
|
@chars = @{$passwdconf{'chars'}}; |
|
} |
|
my $encpass = $env{'form.upass'}; |
|
if ($encpass eq '') { |
|
$msg = &mt('Password retrieved was blank.'). |
|
'<br /><p>'.&mt('[_1]Return[_2] to the previous page to try again.', |
|
'<a href="javascript:document.retryemail.submit();">','</a>'); |
|
$earlyout = 1; |
|
} else { |
|
# Split the logtoken to retrieve the DES key and decrypt the encypted password |
|
my ($key,$caller)=split(/&/,$tmpinfo); |
|
if ($caller eq 'createaccount') { |
|
my $plainpass = &Apache::loncommon::des_decrypt($key,$encpass); |
|
if (($min > 0) || ($max ne '') || (@chars > 0)) { |
|
my $warning = &Apache::loncommon::check_passwd_rules($domain,$plainpass); |
|
if ($warning) { |
|
$msg = $warning. |
|
'<p>'.&mt('[_1]Return[_2] to the previous page to try again.', |
|
'<a href="javascript:document.retryemail.submit();">','</a>'); |
|
$earlyout = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ($earlyout) { |
|
$msg .= '<form name="retryemail" action="/adm/createaccount" method="post" />'. |
|
'<input type="hidden" name="domain" value="'.$domain.'" />'."\n"; |
|
if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { |
|
$msg .= '<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />'."\n"; |
|
} |
|
if ($env{'form.type'}) { |
|
my $usertype = &get_usertype($domain); |
|
if ($usertype ne '') { |
|
$msg .= '<input type="hidden" name="type" value="'.$usertype.'" />'. |
|
'<input type="hidden" name="reportedtype" value="'.&mt('Submit').'" />'."\n"; |
|
} |
|
} |
|
$msg .= '</form></p>'; |
|
return $msg; |
|
} |
|
my $ip = &Apache::lonnet::get_requestor_ip(); |
|
my %info = ('ip' => $ip, |
'time' => $now, |
'time' => $now, |
'domain' => $domain, |
'domain' => $domain, |
'username' => $email, |
'username' => $email, |
Line 940 sub process_mailtoken {
|
Line 1086 sub process_mailtoken {
|
$data{'inststatus'} = $usertype; |
$data{'inststatus'} = $usertype; |
} |
} |
} else { |
} else { |
undef($usertype); |
$disposition = 'approval'; |
} |
} |
} |
} |
delete($data{'usertype'}); |
delete($data{'usertype'}); |
Line 948 sub process_mailtoken {
|
Line 1094 sub process_mailtoken {
|
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if (ref($settings->{'cancreate'}) eq 'HASH') { |
if (ref($settings->{'cancreate'}) eq 'HASH') { |
if (ref($settings->{'cancreate'}{'selfcreateprocessing'}) eq 'HASH') { |
if (ref($settings->{'cancreate'}{'selfcreateprocessing'}) eq 'HASH') { |
$disposition = $settings->{'cancreate'}{'selfcreateprocessing'}{$usertype}; |
if ($usertype ne '') { |
|
$disposition = $settings->{'cancreate'}{'selfcreateprocessing'}{$usertype}; |
|
unless ($disposition =~ /^(approval|automatic)$/) { |
|
$disposition = 'approval'; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 960 sub process_mailtoken {
|
Line 1111 sub process_mailtoken {
|
&create_account($r,$domain,$domdesc,\%data); |
&create_account($r,$domain,$domdesc,\%data); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$msg = $output; |
$msg = $output; |
|
my $ip = &Apache::lonnet::get_requestor_ip(); |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
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 $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,$ip,$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 1027 sub start_session {
|
Line 1179 sub start_session {
|
# |
# |
sub print_dataentry_form { |
sub print_dataentry_form { |
my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$emailusername,$captcha, |
my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$emailusername,$captcha, |
$usertype,$recaptchaversion,$usernameset,$condition) = @_; |
$usertype,$recaptchaversion,$usernameset,$condition,$excluded) = @_; |
my ($error,$output); |
my ($error,$output); |
if (open(my $jsh,"<$include/londes.js")) { |
if (open(my $jsh,"<","$include/londes.js")) { |
while(my $line = <$jsh>) { |
while(my $line = <$jsh>) { |
$r->print($line); |
$r->print($line); |
} |
} |
close($jsh); |
close($jsh); |
$output = &javascript_setforms($now,$emailusername,$captcha,$usertype,$recaptchaversion, |
$output = &javascript_setforms($now,$emailusername,$captcha,$usertype,$recaptchaversion, |
$usernameset,$condition). |
$usernameset,$condition,$excluded). |
"\n".&javascript_checkpass($now,'email'); |
"\n".&javascript_checkpass($now,'email',$domain); |
my ($lkey,$ukey) = &Apache::loncommon::des_keys(); |
my ($lkey,$ukey) = &Apache::loncommon::des_keys(); |
my ($lextkey,$uextkey) = &getkeys($lkey,$ukey); |
my ($lextkey,$uextkey) = &getkeys($lkey,$ukey); |
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', |
my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', |
$lonhost); |
$lonhost); |
$output .= |
my $showsubmit = 1; |
|
my $serverform = |
'<form name="createaccount" method="post" target="_top" action="/adm/createaccount">'; |
'<form name="createaccount" method="post" target="_top" action="/adm/createaccount">'; |
if ($courseid ne '') { |
if ($courseid ne '') { |
$output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n"; |
$serverform .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n"; |
} |
} |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
if (ref($emailusername->{$usertype}) eq 'HASH') { |
foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) { |
foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) { |
$output .= '<input type="hidden" name="'.$field.'" value="" />'."\n"; |
$serverform .= '<input type="hidden" name="'.$field.'" value="" />'."\n"; |
} |
} |
} |
} |
} |
} |
if ($captcha eq 'original') { |
if ($captcha eq 'original') { |
$output .= ' |
$serverform .= ' |
<input type="hidden" name="crypt" value="" /> |
<input type="hidden" name="crypt" value="" /> |
<input type="hidden" name="code" value="" /> |
<input type="hidden" name="code" value="" /> |
'; |
'; |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
if ($recaptchaversion eq '2') { |
if ($recaptchaversion eq '2') { |
$output .= "$captchaform\n"; |
$serverform .= &Apache::lonhtmlcommon::start_pick_box(). |
|
&Apache::lonhtmlcommon::row_title(&mt('Validation').'<b>*</b>', |
|
'LC_pick_box_title', |
|
'LC_oddrow_value')."\n". |
|
$captchaform. |
|
&Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::row_title()."\n". |
|
'<br /><input type="button" name="createaccount" value="'. |
|
&mt('Create account').'" onclick="checkpass('."'createaccount','newemail'".')" />'. |
|
&Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::end_pick_box(); |
undef($captchaform); |
undef($captchaform); |
|
undef($showsubmit); |
} else { |
} else { |
$output .= ' |
$serverform .= ' |
<input type="hidden" name="recaptcha_challenge_field" value="" /> |
<input type="hidden" name="recaptcha_challenge_field" value="" /> |
<input type="hidden" name="recaptcha_response_field" value="" /> |
<input type="hidden" name="recaptcha_response_field" value="" /> |
'; |
'; |
} |
} |
} |
} |
if ($usertype ne '') { |
if ($usertype ne '') { |
$output .= '<input type="hidden" name="type" value="'. |
$serverform .= '<input type="hidden" name="type" value="'. |
&HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n"; |
&HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n"; |
} |
} |
if ($usernameset) { |
if ($usernameset eq 'free') { |
$output .= '<input type="hidden" name="username" value="" />'."\n"; |
$serverform .= '<input type="hidden" name="username" value="" />'."\n"; |
} |
} |
$output .= <<"ENDSERVERFORM"; |
$serverform .= <<"ENDSERVERFORM"; |
<input type="hidden" name="logtoken" value="$logtoken" /> |
<input type="hidden" name="logtoken" value="$logtoken" /> |
<input type="hidden" name="serverid" value="$lonhost" /> |
<input type="hidden" name="serverid" value="$lonhost" /> |
<input type="hidden" name="uname" value="" /> |
<input type="hidden" name="uname" value="" /> |
Line 1088 sub print_dataentry_form {
|
Line 1252 sub print_dataentry_form {
|
ENDSERVERFORM |
ENDSERVERFORM |
my $beginclientform = '<form name="newemail" method="post" action="" '. |
my $beginclientform = '<form name="newemail" method="post" action="" '. |
'onsubmit="return checkpass('."'createaccount','newemail'".');">'."\n"; |
'onsubmit="return checkpass('."'createaccount','newemail'".');">'."\n"; |
my $endclientform = '<input type="hidden" name="udom" value="'.$domain.'" />'."\n". |
my $endclientform; |
'<input type="hidden" name="lextkey" value="'.$lextkey.'" />'."\n". |
unless ($showsubmit) { |
'<input type="hidden" name="uextkey" value="'.$uextkey.'" />'."\n". |
if ($usertype ne '') { |
'</form>'."\n". |
$endclientform = '<input type="hidden" name="type" value="'. |
'<p class="LC_info">'.&mt('Fields marked [_1]*[_2] are required.','<b>','</b>').'</p>'; |
&HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n"; |
|
} |
|
} |
|
$endclientform .= '<input type="hidden" name="udom" value="'.$domain.'" />'."\n". |
|
'<input type="hidden" name="lextkey" value="'.$lextkey.'" />'."\n". |
|
'<input type="hidden" name="uextkey" value="'.$uextkey.'" />'."\n". |
|
'</form>'."\n"; |
my ($datatable,$rowcount) = |
my ($datatable,$rowcount) = |
&Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate', |
&Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate', |
'','',$now,$captchaform, |
'','','',$now,$captchaform, |
$emailusername,$usertype, |
$emailusername,$usertype, |
$usernameset,$condition); |
$usernameset,$condition,$excluded, |
|
$showsubmit); |
if ($rowcount) { |
if ($rowcount) { |
$output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform; |
$output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform.'</div>'."\n". |
|
'<div class="LC_clear_float_footer"></div>'."\n"; |
} else { |
} else { |
$output .= $beginclientform.$endclientform; |
$output .= $beginclientform.$endclientform; |
} |
} |
if ($rowcount) { |
$output .= $serverform. |
$output .= '</div>'."\n". |
'<p class="LC_info">'. |
'<div class="LC_clear_float_footer"></div>'."\n"; |
&mt('Fields marked [_1]*[_2] are required.','<b>','</b>'). |
} |
'</p>'; |
} else { |
} else { |
$output = &mt('Could not load javascript file [_1]','<tt>londes.js</tt>'); |
$output = &mt('Could not load javascript file [_1]','<tt>londes.js</tt>'); |
} |
} |
Line 1120 ENDSERVERFORM
|
Line 1292 ENDSERVERFORM
|
sub get_creation_controls { |
sub get_creation_controls { |
my ($domain,$usercreation) = @_; |
my ($domain,$usercreation) = @_; |
my (@cancreate,@statustocreate,@statusforemail,$emailusername,$processing, |
my (@cancreate,@statustocreate,@statusforemail,$emailusername,$processing, |
$verification,$emaildomain,$othertitle,$usertypes,$types); |
$emailoptions,$verification,$emaildomain,$othertitle,$usertypes,$types); |
if (ref($usercreation) eq 'HASH') { |
if (ref($usercreation) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}) eq 'HASH') { |
($othertitle,$usertypes,$types) = |
($othertitle,$usertypes,$types) = |
Line 1152 sub get_creation_controls {
|
Line 1324 sub get_creation_controls {
|
if (ref($usercreation->{'cancreate'}{'selfcreateprocessing'}) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}{'selfcreateprocessing'}) eq 'HASH') { |
$processing = $usercreation->{'cancreate'}{'selfcreateprocessing'}; |
$processing = $usercreation->{'cancreate'}{'selfcreateprocessing'}; |
} |
} |
|
if (ref($usercreation->{'cancreate'}{'emailoptions'}) eq 'HASH') { |
|
$emailoptions = $usercreation->{'cancreate'}{'emailoptions'}; |
|
} |
if (ref($usercreation->{'cancreate'}{'emailverified'}) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}{'emailverified'}) eq 'HASH') { |
$verification = $usercreation->{'cancreate'}{'emailverified'}; |
$verification = $usercreation->{'cancreate'}{'emailverified'}; |
} |
} |
Line 1162 sub get_creation_controls {
|
Line 1337 sub get_creation_controls {
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
my @emailtypes; |
my @emailtypes; |
if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') { |
if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') { |
@emailtypes = @{$domdefaults{'inststatusguest'}}; |
@statusforemail = @{$domdefaults{'inststatusguest'}}; |
if (@emailtypes) { |
unless (@statusforemail) { |
unless (grep(/^default$/,@emailtypes)) { |
my @okcreate; |
push(@emailtypes,'default'); |
foreach my $poss (@cancreate) { |
} |
unless ($poss eq 'email') { |
foreach my $type (@emailtypes) { |
push(@okcreate,$poss); |
if ($processing->{$type} ne 'notinuse') { |
|
unless (grep(/^$type$/,@statusforemail)) { |
|
push(@statusforemail,$type); |
|
} |
|
} |
|
} |
|
unless (@statusforemail) { |
|
my @okcreate; |
|
foreach my $poss (@cancreate) { |
|
unless ($poss eq 'email') { |
|
push(@okcreate,$poss); |
|
} |
|
} |
} |
@cancreate = @okcreate; |
|
} |
} |
|
@cancreate = @okcreate; |
} |
} |
} |
} |
} |
} |
Line 1200 sub get_creation_controls {
|
Line 1363 sub get_creation_controls {
|
} |
} |
} |
} |
return (\@cancreate,\@statustocreate,\@statusforemail,$emailusername, |
return (\@cancreate,\@statustocreate,\@statusforemail,$emailusername, |
$verification,$emaildomain,$types,$usertypes,$othertitle); |
$emailoptions,$verification,$emaildomain,$types,$usertypes,$othertitle); |
} |
} |
|
|
sub create_account { |
sub create_account { |
Line 1240 sub create_account {
|
Line 1403 sub create_account {
|
|
|
my ($key,$caller)=split(/&/,$dataref->{'tmpinfo'}); |
my ($key,$caller)=split(/&/,$dataref->{'tmpinfo'}); |
if ($caller eq 'createaccount') { |
if ($caller eq 'createaccount') { |
my $upass = &Apache::loncommon::des_decrypt($key,$encpass); |
my $upass; |
|
if ($encpass eq '') { |
|
$output = &mt('Password retrieved was blank.'); |
|
return ('fail',$error.$output.$end.$rtnlink); |
|
} else { |
|
$upass = &Apache::loncommon::des_decrypt($key,$encpass); |
|
} |
|
|
# See if we are allowed to use the proposed student/employee ID, |
# See if we are allowed to use the proposed student/employee ID, |
# as per domain rules; if not, student/employee will be left blank. |
# as per domain rules; if not, student/employee will be left blank. |
Line 1270 sub create_account {
|
Line 1439 sub create_account {
|
unless (($inststatus eq 'default') || ($inststatus eq '')) { |
unless (($inststatus eq 'default') || ($inststatus eq '')) { |
&Apache::lonnet::put('environment',{inststatus => $inststatus},$domain,$username); |
&Apache::lonnet::put('environment',{inststatus => $inststatus},$domain,$username); |
} |
} |
$output .= '<br />'.&mt('Home server: [_1]',$uhome).' '. |
$output .= '<br />'.&mt('Home Server').": $uhome ". |
&Apache::lonnet::hostname($uhome).'<br /><br />'; |
&Apache::lonnet::hostname($uhome).'<br /><br />'; |
return ('ok',$output,$uhome); |
return ('ok',$output,$uhome); |
} else { |
} else { |
Line 1380 sub login_failure_msg {
|
Line 1549 sub login_failure_msg {
|
} else { |
} else { |
$url = "/adm/createaccount"; |
$url = "/adm/createaccount"; |
} |
} |
my $output = '<h4>'.&mt('Authentication failed').'</h4><div class="LC_warning">'. |
my $output = '<h3 class="LC_heading_3">'.&mt('Authentication failed').'</h3><div class="LC_warning">'. |
&mt('Username and/or password could not be authenticated.'). |
&mt('Username and/or password could not be authenticated.'). |
'</div>'. |
'</div>'. |
&mt('Please check the username and password.').'<br /><br />'; |
&mt('Please check the username and password.').'<br /><br />'; |
Line 1443 sub username_check {
|
Line 1612 sub username_check {
|
'<input type="hidden" name="udom" value="'.$domain.'" />'."\n". |
'<input type="hidden" name="udom" value="'.$domain.'" />'."\n". |
'<input type="hidden" name="phase" value="username_activation" />'; |
'<input type="hidden" name="phase" value="username_activation" />'; |
my $now = time; |
my $now = time; |
my %info = ('ip' => $ENV{'REMOTE_ADDR'}, |
my $ip = &Apache::lonnet::get_requestor_ip(); |
|
my %info = ('ip' => $ip, |
'time' => $now, |
'time' => $now, |
'domain' => $domain, |
'domain' => $domain, |
'username' => $username); |
'username' => $username); |
Line 1458 sub username_check {
|
Line 1628 sub username_check {
|
} |
} |
} |
} |
if ($checkfail) { |
if ($checkfail) { |
$msg = '<br /><h4>'.&mt('Account creation unavailable').'</h4>'; |
$msg = '<br /><h3 class="LC_heading_3">'.&mt('Account creation unavailable').'</h3>'; |
if ($checkfail eq 'username') { |
if ($checkfail eq 'username') { |
$msg .= '<span class="LC_warning">'. |
$msg .= '<span class="LC_warning">'. |
&mt('A LON-CAPA account may not be created with the username you use.'). |
&mt('A LON-CAPA account may not be created with the username you use.'). |
Line 1484 sub username_check {
|
Line 1654 sub username_check {
|
if ($rowcount) { |
if ($rowcount) { |
if ($editable) { |
if ($editable) { |
if ($courseid ne '') { |
if ($courseid ne '') { |
$msg = '<br /><h4>'.&mt('User information').'</h4>'; |
$msg = '<br /><h3 class="LC_heading_3">'.&mt('User information').'</h3>'; |
} |
} |
$msg .= &mt('To create one, use the table below to provide information about yourself, then click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />'; |
$msg .= &mt('To create one, use the table below to provide information about yourself, then click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />'; |
} else { |
} else { |
if ($courseid ne '') { |
if ($courseid ne '') { |
$msg = '<h4>'.&mt('Review user information').'</h4>'; |
$msg = '<h3 class="LC_heading_3">'.&mt('Review user information').'</h3>'; |
} |
} |
$msg .= &mt('A user account will be created with information displayed in the table below, when you click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />'; |
$msg .= &mt('A user account will be created with information displayed in the table below, when you click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />'; |
} |
} |
} else { |
} else { |
if ($courseid ne '') { |
if ($courseid ne '') { |
$msg = '<h4>'.&mt('Confirmation').'</h4>'; |
$msg = '<h3 class="LC_heading_3">'.&mt('Confirmation').'</h3>'; |
} |
} |
$msg .= &mt('Confirm that you wish to create an account.'); |
$msg .= &mt('Confirm that you wish to create an account.'); |
} |
} |
Line 1636 sub check_id {
|
Line 1806 sub check_id {
|
|
|
sub invalid_state { |
sub invalid_state { |
my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_; |
my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_; |
my $msg = '<h3>'.&mt('Account creation unavailable').'</h3><span class="LC_error">'; |
my $msg = '<h2 class="LC_heading_2">'.&mt('Account creation unavailable').'</h2><span class="LC_error">'; |
if ($error eq 'baduseremail') { |
if ($error eq 'baduseremail') { |
$msg .= &mt('The e-mail address you provided does not appear to be a valid address.'); |
$msg .= &mt('The e-mail address you provided does not appear to be a valid address.'); |
} elsif ($error eq 'badusername') { |
} elsif ($error eq 'badusername') { |
Line 1647 sub invalid_state {
|
Line 1817 sub invalid_state {
|
$msg .= &mt('Username rules at this institution do not allow the e-mail address you provided to be used as a username.'); |
$msg .= &mt('Username rules at this institution do not allow the e-mail address you provided to be used as a username.'); |
} elsif ($error eq 'userformat') { |
} elsif ($error eq 'userformat') { |
$msg .= &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.'); |
$msg .= &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.'); |
} elsif ($error eq 'captcha') { |
|
$msg .= &mt('Validation of the code you entered failed.'); |
|
} elsif ($error eq 'noemails') { |
} elsif ($error eq 'noemails') { |
$msg .= &mt('Creation of a new user account using an e-mail address as username is not permitted at this LON-CAPA institution.'); |
$msg .= &mt('Creation of a new user account using an e-mail address as username is not permitted at this LON-CAPA institution.'); |
} elsif ($error eq 'emailfail') { |
} elsif ($error eq 'emailfail') { |
Line 1785 sub store_request {
|
Line 1953 sub store_request {
|
} |
} |
|
|
sub guest_format_check { |
sub guest_format_check { |
my ($useremail,$domain,$cancreate,$settings) = @_; |
my ($useremail,$domain,$cancreate,$settings,$usertype) = @_; |
my ($login,$format_match,$format_msg,@user_rules); |
my ($login,$format_match,$format_msg,@user_rules); |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if (ref($settings->{'email_rule'}) eq 'ARRAY') { |
if (ref($settings->{'email_rule'}) eq 'ARRAY') { |
push(@user_rules,@{$settings->{'email_rule'}}); |
push(@user_rules,@{$settings->{'email_rule'}}); |
|
} elsif (ref($settings->{'email_rule'}) eq 'HASH') { |
|
if (ref($settings->{'email_rule'}->{$usertype}) eq 'ARRAY') { |
|
push(@user_rules,@{$settings->{'email_rule'}->{$usertype}}); |
|
} |
} |
} |
} |
} |
if (@user_rules > 0) { |
if (@user_rules > 0) { |
Line 1825 sub sso_logout_frag {
|
Line 1997 sub sso_logout_frag {
|
if (defined($r->dir_config('lonSSOUserLogoutMessageFile_'.$domain))) { |
if (defined($r->dir_config('lonSSOUserLogoutMessageFile_'.$domain))) { |
my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile_'.$domain); |
my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile_'.$domain); |
if (-e $msgfile) { |
if (-e $msgfile) { |
open(my $fh,"<$msgfile"); |
open(my $fh,"<",$msgfile); |
$endsessionmsg = join('',<$fh>); |
$endsessionmsg = join('',<$fh>); |
close($fh); |
close($fh); |
} |
} |
} elsif (defined($r->dir_config('lonSSOUserLogoutMessageFile'))) { |
} elsif (defined($r->dir_config('lonSSOUserLogoutMessageFile'))) { |
my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile'); |
my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile'); |
if (-e $msgfile) { |
if (-e $msgfile) { |
open(my $fh,"<$msgfile"); |
open(my $fh,"<",$msgfile); |
$endsessionmsg = join('',<$fh>); |
$endsessionmsg = join('',<$fh>); |
close($fh); |
close($fh); |
} |
} |
Line 1951 function checkVerification() {
|
Line 2123 function checkVerification() {
|
if (curr == types[j]) { |
if (curr == types[j]) { |
if (!cancreate) { |
if (!cancreate) { |
alert('Creation of an account via verification by e-mail unavailable for user type: "'+names[j]+'"'); |
alert('Creation of an account via verification by e-mail unavailable for user type: "'+names[j]+'"'); |
|
setElements(); |
} |
} |
break; |
break; |
} |
} |
Line 1974 sub username_js {
|
Line 2147 sub username_js {
|
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
|
|
function toggleDisplay(caller,divid) { |
function toggleUsernameDisp(caller,divid) { |
if (document.getElementById(divid)) { |
if (document.getElementById(divid)) { |
if (caller.checked) { |
if (caller.checked) { |
if (caller.value == '1') { |
if (caller.value == '1') { |