--- loncom/auth/lonauth.pm 2011/08/17 03:52:36 1.118 +++ loncom/auth/lonauth.pm 2011/09/29 13:43:22 1.119 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.118 2011/08/17 03:52:36 raeburn Exp $ +# $Id: lonauth.pm,v 1.119 2011/09/29 13:43:22 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,7 +40,7 @@ use Apache::lonmenu(); use Apache::createaccount; use Fcntl qw(:flock); use Apache::lonlocal; -use Apache::File (); +use Apache::File(); use HTML::Entities; # ------------------------------------------------------------ Successful login @@ -329,21 +329,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, @@ -357,9 +351,7 @@ 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; @@ -372,9 +364,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);