--- loncom/auth/lonauth.pm 2011/09/27 20:18:45 1.101.8.7 +++ loncom/auth/lonauth.pm 2011/09/29 14:05:41 1.101.8.8 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.101.8.7 2011/09/27 20:18:45 raeburn Exp $ +# $Id: lonauth.pm,v 1.101.8.8 2011/09/29 14:05:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,6 +40,7 @@ use Apache::lonmenu(); use Apache::createaccount; use Fcntl qw(:flock); use Apache::lonlocal; +use Apache::File(); use HTML::Entities; # ------------------------------------------------------------ Successful login @@ -331,21 +332,15 @@ sub handler { } # ---------------------------------------------------------------- Authenticate - my @cancreate; + my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'}); - if (ref($domconfig{'usercreation'}) eq 'HASH') { - if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { - 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'}); - } - } - } + my ($cancreate,$statustocreate) = + &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'}); my $defaultauth; - if (grep(/^login$/,@cancreate)) { - $defaultauth = 1; + if (ref($cancreate) eq 'ARRAY') { + if (grep(/^login$/,@{$cancreate})) { + $defaultauth = 1; + } } my $clientcancheckhost = 1; my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass, @@ -359,12 +354,10 @@ sub handler { \%form); return OK; } elsif ($authhost eq 'no_account_on_host') { - my %domconfig = - &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'}); - if (grep(/^login$/,@cancreate)) { + if ($defaultauth) { my $domdesc = &Apache::lonnet::domain($form{'udom'},'description'); unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) { - return OK; + return OK; } my $start_page = &Apache::loncommon::start_page('Create a user account in LON-CAPA', @@ -375,9 +368,11 @@ sub handler { &Apache::loncommon::build_recipient_list(undef,'helpdeskmail', $form{'udom'},$origmail); my ($contact_email) = split(',',$contacts); - my $output = &Apache::createaccount::username_check($form{'uname'}, - $form{'udom'},$domdesc,'', - $lonhost,$contact_email,$contact_name); + my $output = + &Apache::createaccount::username_check($form{'uname'},$form{'udom'}, + $domdesc,'',$lonhost, + $contact_email,$contact_name, + undef,$statustocreate); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; &Apache::createaccount::print_header($r,$start_page);