--- loncom/interface/lonuserutils.pm 2019/08/22 19:31:20 1.184.4.4 +++ loncom/interface/lonuserutils.pm 2021/08/24 00:22:59 1.184.4.10 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.184.4.4 2019/08/22 19:31:20 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.184.4.10 2021/08/24 00:22:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -543,13 +543,15 @@ END case 'krb': alertmsg = '$alert{'krb'}'; break; - case 'loc': case 'int': alertmsg = '$alert{'ipass'}'; break; case 'fsys': alertmsg = '$alert{'ipass'}'; break; + case 'loc': + alertmsg = ''; + break; default: alertmsg = ''; } @@ -655,10 +657,12 @@ sub passwd_validation_js { my %passwdconf = &Apache::lonnet::get_passwdconf($domain); my ($min,$max,@chars,$numrules,$intargjs,%alert); $numrules = 0; + $min = $Apache::lonnet::passwdmin; if (ref($passwdconf{'chars'}) eq 'ARRAY') { if ($passwdconf{'min'} =~ /^\d+$/) { - $min = $passwdconf{'min'}; - $numrules ++; + if ($passwdconf{'min'} > $min) { + $min = $passwdconf{'min'}; + } } if ($passwdconf{'max'} =~ /^\d+$/) { $max = $passwdconf{'max'}; @@ -668,11 +672,11 @@ sub passwd_validation_js { if (@chars) { $numrules ++; } - } else { - $min = 7; + } + if ($min > 0) { $numrules ++; } - if (($min ne '') || ($max ne '') || (@chars > 0)) { + if (($min > 0) || ($max ne '') || (@chars > 0)) { my $alertmsg = &mt('Initial password did not satisfy requirement(s):').'\n\n'; if ($min) { $alert{'min'} = &mt('minimum [quant,_1,character]',$min).'\n'; @@ -3659,6 +3663,8 @@ END setSections(formname,'$crstype'); if (seccheck == 'ok') { opener.document.$callingform.newsecs.value = formname.sections.value; + } else { + return; } END } else { @@ -4931,6 +4937,16 @@ sub upfile_drop_add { my (%userres,%authres,%roleres,%idres); my $singlesec = ''; if ($role eq 'st') { + if (($context eq 'domain') && ($changeauth eq 'Yes') && (!$newuser)) { + if ((&Apache::lonnet::allowed('mau',$userdomain)) && + (&Apache::lonnet::homeserver($username,$userdomain) ne 'no_host')) { + if ((($amode =~ /^krb4|krb5|internal$/) && $password ne '') || + ($amode eq 'localauth')) { + $authresult = + &Apache::lonnet::modifyuserauth($userdomain,$username,$amode,$password); + } + } + } my $sec; if (ref($userinfo{$i}{'sections'}) eq 'ARRAY') { if (@secs > 0) { @@ -4972,16 +4988,16 @@ sub upfile_drop_add { } } } - if (!$multiple) { - ($userresult,$authresult,$roleresult,$idresult) = - &modifyuserrole($context,$setting, - $changeauth,$cid,$userdomain,$username, - $id,$amode,$password,$fname, - $mname,$lname,$gen,$singlesec, - $env{'form.forceid'},$desiredhost, - $email,$role,$enddate,$startdate, - $checkid,$inststatus); - } + } + if (!$multiple) { + ($userresult,$authresult,$roleresult,$idresult) = + &modifyuserrole($context,$setting, + $changeauth,$cid,$userdomain,$username, + $id,$amode,$password,$fname, + $mname,$lname,$gen,$singlesec, + $env{'form.forceid'},$desiredhost, + $email,$role,$enddate,$startdate, + $checkid,$inststatus); } } if ($multiple) { @@ -5101,7 +5117,11 @@ sub passwdrule_alerts { my %passwdconf = &Apache::lonnet::get_passwdconf($domain); $warning = ''.&mt('Password requirement(s) unmet for one or more users:').'