version 1.65, 2014/05/05 21:28:10
|
version 1.72.4.1, 2018/09/11 18:55:57
|
Line 277 sub handler {
|
Line 277 sub handler {
|
} elsif (!$token) { |
} elsif (!$token) { |
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
my $now=time; |
my $now=time; |
my $gotlondes; |
if ((grep(/^login$/,@{$cancreate})) && (!grep(/^email$/,@{$cancreate}))) { |
if (grep(/^login$/,@{$cancreate})) { |
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); |
$r->print(&javascript_setforms($now)); |
$r->print(&javascript_setforms($now)); |
$gotlondes = 1; |
|
} |
} |
} |
} |
if (grep(/^email$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
Line 293 sub handler {
|
Line 291 sub handler {
|
} |
} |
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,$gotlondes,$emailusername, |
$include,$courseid,$emailusername,$usertype); |
$usertype); |
|
} |
} |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 322 sub print_footer {
|
Line 319 sub print_footer {
|
$r->print('<form name="backupcrumbs" method="post" action="">'. |
$r->print('<form name="backupcrumbs" method="post" action="">'. |
&Apache::lonhtmlcommon::echo_form_input(['backto','logtoken', |
&Apache::lonhtmlcommon::echo_form_input(['backto','logtoken', |
'token','serverid','uname','upass','phase','create_with_email', |
'token','serverid','uname','upass','phase','create_with_email', |
'code','crypt','cfirstname','clastname', |
'code','crypt','cfirstname','clastname','g-recaptcha-response', |
'recaptcha_challenge_field','recaptcha_response_field', |
'recaptcha_challenge_field','recaptcha_response_field', |
'cmiddlename','cgeneration','cpermanentemail','cid']). |
'cmiddlename','cgeneration','cpermanentemail','cid']). |
'</form>'); |
'</form>'); |
Line 369 sub selfenroll_crumbs {
|
Line 366 sub selfenroll_crumbs {
|
} |
} |
|
|
sub javascript_setforms { |
sub javascript_setforms { |
my ($now,$emailusername,$captcha,$usertype) = @_; |
my ($now,$emailusername,$captcha,$usertype,$recaptchaversion) = @_; |
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 385 sub javascript_setforms {
|
Line 382 sub javascript_setforms {
|
$setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". |
$setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". |
' server.elements.crypt.value=client.elements.crypt.value;'."\n"; |
' server.elements.crypt.value=client.elements.crypt.value;'."\n"; |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$setuserinfo .= |
if ($recaptchaversion ne '2') { |
|
$setuserinfo .= |
' server.elements.recaptcha_challenge_field.value=client.elements.recaptcha_challenge_field.value;'."\n". |
' server.elements.recaptcha_challenge_field.value=client.elements.recaptcha_challenge_field.value;'."\n". |
' 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 (@required) { |
if (@required) { |
my $missprompt = &mt('One or more required fields are currently blank.'); |
my $missprompt = &mt('One or more required fields are currently blank.'); |
|
&js_escape(\$missprompt); |
my $reqstr = join("','",@required); |
my $reqstr = join("','",@required); |
$requiredchk = <<"ENDCHK"; |
$requiredchk = <<"ENDCHK"; |
var requiredfields = new Array('$reqstr'); |
var requiredfields = new Array('$reqstr'); |
Line 433 $requiredchk
|
Line 433 $requiredchk
|
initkeys(); |
initkeys(); |
|
|
server.elements.upass.value |
server.elements.upass.value |
= crypted(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=''; |
Line 446 $setuserinfo
|
Line 446 $setuserinfo
|
} |
} |
return false; |
return false; |
} |
} |
|
|
// ]]> |
// ]]> |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
|
if (($captcha eq 'recaptcha') && ($recaptchaversion eq '2')) { |
|
$js .= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n"; |
|
} |
return $js; |
return $js; |
} |
} |
|
|
sub javascript_checkpass { |
sub javascript_checkpass { |
my ($now,$context) = @_; |
my ($now,$context) = @_; |
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.'); |
|
&js_escape(\$nopass); |
|
&js_escape(\$mismatchpass); |
my $js = <<"ENDSCRIPT"; |
my $js = <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 490 ENDSCRIPT
|
Line 496 ENDSCRIPT
|
} |
} |
|
|
sub javascript_validmail { |
sub javascript_validmail { |
my %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', |
); |
); |
my $output = "\n".'<script type="text/javascript">'."\n". |
my $output = "\n".'<script type="text/javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
&Apache::lonhtmlcommon::javascript_valid_email()."\n"; |
&Apache::lonhtmlcommon::javascript_valid_email()."\n"; |
|
&js_escape(\%js_lt); |
$output .= <<"ENDSCRIPT"; |
$output .= <<"ENDSCRIPT"; |
function validate_email(client) { |
function validate_email(client) { |
field = client.uname; |
field = client.uname; |
if (validmail(field) == false) { |
if (validmail(field) == false) { |
alert("$lt{'email'}: "+field.value+" $lt{'notv'}."); |
alert("$js_lt{'email'}: "+field.value+" $js_lt{'notv'}."); |
return false; |
return false; |
} |
} |
return true; |
return true; |
Line 512 ENDSCRIPT
|
Line 519 ENDSCRIPT
|
} |
} |
|
|
sub print_username_form { |
sub print_username_form { |
my ($r,$domain,$domdesc,$cancreate,$now,$lonhost,$include,$courseid,$gotlondes,$emailusername, |
my ($r,$domain,$domdesc,$cancreate,$now,$lonhost,$include,$courseid,$emailusername, |
$usertype) = @_; |
$usertype) = @_; |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
unam => 'username', |
unam => 'username', |
Line 542 sub print_username_form {
|
Line 549 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,$error,$captcha) = &Apache::loncommon::captcha_display('usercreation',$lonhost); |
my ($captchaform,$error,$captcha,$recaptchaversion) = |
|
&Apache::loncommon::captcha_display('usercreation',$lonhost); |
if ($error) { |
if ($error) { |
my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount'; |
my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount'; |
if ($courseid ne '') { |
if ($courseid ne '') { |
Line 571 sub print_username_form {
|
Line 579 sub print_username_form {
|
$lt{'yopw'}.'<br />'; |
$lt{'yopw'}.'<br />'; |
} |
} |
$output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform, |
$output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform, |
$courseid,$gotlondes,$emailusername,$captcha, |
$courseid,$emailusername,$captcha,$usertype, |
$usertype); |
$recaptchaversion); |
} |
} |
$output .= '</div>'; |
$output .= '</div>'; |
} |
} |
Line 860 sub process_mailtoken {
|
Line 868 sub process_mailtoken {
|
|
|
sub start_session { |
sub start_session { |
my ($r,$username,$domain,$uhome,$courseid,$token) = @_; |
my ($r,$username,$domain,$uhome,$courseid,$token) = @_; |
|
my ($is_balancer) = &Apache::lonnet::check_loadbalancing($username,$domain); |
if ($r->dir_config('lonBalancer') eq 'yes') { |
if ($is_balancer) { |
Apache::lonauth::success($r, $username, $domain, $uhome, |
Apache::lonauth::success($r, $username, $domain, $uhome, |
'noredirect', undef, {}); |
'noredirect', undef, {}); |
|
|
Line 875 sub start_session {
|
Line 883 sub start_session {
|
($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'), |
($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'), |
undef, {}); |
undef, {}); |
} |
} |
|
|
return; |
return; |
} |
} |
|
|
Line 885 sub start_session {
|
Line 892 sub start_session {
|
# Stores token to store DES-key and stage during creation session |
# Stores token to store DES-key and stage during creation session |
# |
# |
sub print_dataentry_form { |
sub print_dataentry_form { |
my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$gotlondes,$emailusername,$captcha, |
my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$emailusername,$captcha, |
$usertype) = @_; |
$usertype,$recaptchaversion) = @_; |
my ($error,$output); |
my ($error,$output); |
unless ($gotlondes) { |
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)."\n"; |
"\n".&javascript_checkpass($now,'email'); |
$gotlondes = 1; |
|
} |
|
} |
|
if ($gotlondes) { |
|
$output .= &javascript_checkpass($now,'email'); |
|
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', |
Line 923 sub print_dataentry_form {
|
Line 925 sub print_dataentry_form {
|
<input type="hidden" name="code" value="" /> |
<input type="hidden" name="code" value="" /> |
'; |
'; |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$output .= ' |
if ($recaptchaversion eq '2') { |
|
$output .= "$captchaform\n"; |
|
undef($captchaform); |
|
} else { |
|
$output .= ' |
<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="" /> |
'; |
'; |
|
} |
} |
} |
$output .= <<"ENDSERVERFORM"; |
$output .= <<"ENDSERVERFORM"; |
<input type="hidden" name="logtoken" value="$logtoken" /> |
<input type="hidden" name="logtoken" value="$logtoken" /> |
Line 1003 sub get_creation_controls {
|
Line 1010 sub get_creation_controls {
|
if (ref($usercreation->{'cancreate'}{'emailusername'}) eq 'HASH') { |
if (ref($usercreation->{'cancreate'}{'emailusername'}) eq 'HASH') { |
$emailusername = $usercreation->{'cancreate'}{'emailusername'}; |
$emailusername = $usercreation->{'cancreate'}{'emailusername'}; |
} else { |
} else { |
$emailusername = {'lastname' => '1', 'firstname' => 1, }; |
$emailusername = { |
|
default => { |
|
'lastname' => '1', |
|
'firstname' => 1, |
|
}, |
|
}; |
} |
} |
} |
} |
} |
} |
Line 1230 sub username_check {
|
Line 1242 sub username_check {
|
$output = '<form method="post" action="/adm/createaccount">'; |
$output = '<form method="post" action="/adm/createaccount">'; |
if (ref($shibenv) eq 'HASH') { |
if (ref($shibenv) eq 'HASH') { |
foreach my $key (keys(%{$shibenv})) { |
foreach my $key (keys(%{$shibenv})) { |
$inst_results{$username.':'.$domain}{$key} = $shibenv->{$key}; |
if ($ENV{$shibenv->{$key}} ne '') { |
|
$inst_results{$username.':'.$domain}{$key} = $ENV{$shibenv->{$key}}; |
|
} |
} |
} |
} |
} |
(my $datatable,$rowcount,$editable) = |
(my $datatable,$rowcount,$editable) = |
Line 1623 sub sso_logout_frag {
|
Line 1637 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); |
} |
} |