--- loncom/interface/createaccount.pm 2021/12/12 22:10:45 1.72.4.7 +++ loncom/interface/createaccount.pm 2017/07/26 19:45:45 1.73 @@ -4,7 +4,7 @@ # kerberos, or SSO) or an e-mail address. Requests to use an e-mail address as # username may be processed automatically, or may be queued for approval. # -# $Id: createaccount.pm,v 1.72.4.7 2021/12/12 22:10:45 raeburn Exp $ +# $Id: createaccount.pm,v 1.73 2017/07/26 19:45:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,7 +37,6 @@ use Apache::lonacc; use Apache::lonnet; use Apache::loncommon; use Apache::lonhtmlcommon; -use Apache::lonuserutils; use Apache::lonlocal; use Apache::lonauth; use Apache::resetpw; @@ -151,7 +150,7 @@ sub handler { my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$domain); my ($cancreate,$statustocreate,$statusforemail,$emailusername, - $emailoptions,$verification,$emaildomain,$types,$usertypes,$othertitle) = + $verification,$emaildomain,$types,$usertypes,$othertitle) = &get_creation_controls($domain,$domconfig{'usercreation'}); my ($additems,$pagetitle); if (ref($cancreate) eq 'ARRAY') { @@ -159,15 +158,14 @@ sub handler { ($env{'form.create_with_email'})) { if ((grep(/^email$/,@{$cancreate})) && (ref($statusforemail) eq 'ARRAY')) { my $usertype = &get_usertype($domain); - if ((($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) && - (@{$statusforemail} > 0)) { + if (($usertype ne '') && (grep(/^\Q$usertype\E$/,@{$statusforemail}))) { + $js .= &username_js(); + } elsif (($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) { $js .= &setelements_js($statusforemail,$types,$usertypes,$othertitle); $additems = {'add_entries' => { 'onload' => "setElements();"} }; - if ((@{$cancreate} == 1) && (@{$statusforemail} > 0)) { + if (@{$cancreate} == 1) { $pagetitle = 'Select affiliation'; } - } else { - $js .= &username_js(); } } } @@ -257,32 +255,18 @@ sub handler { return OK; } } - my ($usernameset,$condition,$excluded,$hascustom); + my ($usernameset,$condition); if ((grep(/^email$/,@{$cancreate})) && (($env{'form.create_with_email'}) || ((!$token) && ($env{'form.phase'} eq '')))) { my $usertype = &get_usertype($domain); - if ($usertype eq '') { - $usertype = 'default'; - } if (ref($verification) eq 'HASH') { - if ($verification->{$usertype} =~ /^(free|first)$/) { - $usernameset = $verification->{$usertype}; - } - } - if (ref($emailoptions) eq 'HASH') { - if ($emailoptions->{$usertype} =~ /^(inst|noninst)$/) { - my $chosen = $1; + if ($verification->{$usertype} eq 'other') { + $usernameset = 1; if (ref($emaildomain) eq 'HASH') { - if (ref($emaildomain->{$usertype}) eq 'HASH') { - if ($chosen eq 'inst') { - $condition = $emaildomain->{$usertype}->{$chosen}; - } else { - $excluded = $emaildomain->{$usertype}->{$chosen}; - } + if ($emaildomain->{$usertype} ne '') { + $condition = $emaildomain->{$usertype}; } } - } elsif ($emailoptions->{$usertype} eq 'custom') { - $hascustom = 1; } } } @@ -317,19 +301,16 @@ sub handler { } elsif ($env{'form.create_with_email'}) { &print_header($r,$start_page,$courseid); my $usertype = &get_usertype($domain); - if ($usertype eq '') { - $usertype = 'default'; - } $output = &process_email_request($env{'form.uname'},$domain,$domdesc, $contact_name,$contact_email,$cancreate, $lonhost,$domconfig{'usercreation'}, $emailusername,$courseid,$usertype, - $usernameset,$condition,$excluded,$hascustom); + $usernameset,$condition); } elsif (!$token) { &print_header($r,$start_page,$courseid,$pagetitle); my $now=time; if ((grep(/^login$/,@{$cancreate})) && (!grep(/^email$/,@{$cancreate}))) { - if (open(my $jsh,"<","$include/londes.js")) { + if (open(my $jsh,"<$include/londes.js")) { while(my $line = <$jsh>) { $r->print($line); } @@ -338,13 +319,13 @@ sub handler { } } if (grep(/^email$/,@{$cancreate})) { - $r->print(&javascript_validmail($condition)); + $r->print(&javascript_validmail()); } my $usertype = &get_usertype($domain); $output = &print_username_form($r,$domain,$domdesc,$cancreate,$now,$lonhost, $include,$courseid,$emailusername, $statusforemail,$usernameset,$condition, - $excluded,$usertype,$types,$usertypes,$othertitle); + $usertype,$types,$usertypes,$othertitle); } $r->print($output); &print_footer($r); @@ -428,7 +409,7 @@ sub selfenroll_crumbs { } sub javascript_setforms { - my ($now,$emailusername,$captcha,$usertype,$recaptchaversion,$usernameset,$condition,$excluded) = @_; + my ($now,$emailusername,$captcha,$usertype,$recaptchaversion,$usernameset,$condition) = @_; my ($setuserinfo,@required,$requiredchk); if (ref($emailusername) eq 'HASH') { if (ref($emailusername->{$usertype}) eq 'HASH') { @@ -438,9 +419,7 @@ sub javascript_setforms { } $setuserinfo .= ' server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n"; } - if ($usertype ne '') { - $setuserinfo .= ' server.elements.type.value=client.elements.type.value;'."\n"; - } + $setuserinfo .= ' server.elements.type.value=client.elements.type.value;'."\n"; } if ($captcha eq 'original') { $setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". @@ -452,7 +431,7 @@ sub javascript_setforms { ' server.elements.recaptcha_response_field.value=client.elements.recaptcha_response_field.value;'."\n"; } } - if ($usernameset eq 'free') { + if ($usernameset) { $setuserinfo .= ' server.elements.username.value=client.elements.username.value;'."\n"; } @@ -499,8 +478,10 @@ $requiredchk uextkey=client.elements.uextkey.value; lextkey=client.elements.lextkey.value; initkeys(); + server.elements.upass.value = getCrypted(client.elements.upass$now.value); + client.elements.uname.value=''; client.elements.upass$now.value=''; if (context == 'email') { @@ -523,12 +504,10 @@ ENDSCRIPT } sub javascript_checkpass { - my ($now,$context,$domain) = @_; + my ($now,$context) = @_; my $nopass = &mt('You must enter a password.'); my $mismatchpass = &mt('The passwords you entered did not match.')."\n". &mt('Please try again.'); - my ($numrules,$intargjs) = - &Apache::lonuserutils::passwd_validation_js('upass',$domain); &js_escape(\$nopass); &js_escape(\$mismatchpass); my $js = <<"ENDSCRIPT"; @@ -545,10 +524,6 @@ sub javascript_checkpass { return false; } if (upass == upasscheck) { - var numrules = $numrules; - if (numrules > 0) { -$intargjs - } client.elements.upasscheck$now.value=''; if (validate_email(client)) { send(one,two,'$context'); @@ -568,11 +543,9 @@ ENDSCRIPT } sub javascript_validmail { - my ($condition) = @_; my %js_lt = &Apache::lonlocal::texthash ( email => 'The e-mail address you entered', 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".'