version 1.50, 2012/05/17 18:05:42
|
version 1.51, 2012/05/18 04:31:05
|
Line 121 sub handler {
|
Line 121 sub handler {
|
&print_footer($r); |
&print_footer($r); |
return OK; |
return OK; |
} else { |
} else { |
$start_page = |
$start_page = &Apache::loncommon::start_page($title,$js); |
&Apache::loncommon::start_page($title,$js); |
|
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
return OK; |
return OK; |
} |
} |
} |
} |
$start_page = |
$start_page = &Apache::loncommon::start_page($title,$js); |
&Apache::loncommon::start_page($title,$js); |
|
|
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
Line 191 sub handler {
|
Line 189 sub handler {
|
if ($env{'form.phase'} eq 'username_activation') { |
if ($env{'form.phase'} eq 'username_activation') { |
(my $result,$output,$nostart) = |
(my $result,$output,$nostart) = |
&username_activation($r,$env{'form.uname'},$domain,$domdesc, |
&username_activation($r,$env{'form.uname'},$domain,$domdesc, |
$lonhost,$courseid); |
$courseid); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
if ($nostart) { |
if ($nostart) { |
return OK; |
return OK; |
Line 621 sub process_mailtoken {
|
Line 619 sub process_mailtoken {
|
($data{'username'} =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/)) { |
($data{'username'} =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/)) { |
if ($now - $data{'time'} < 7200) { |
if ($now - $data{'time'} < 7200) { |
if ($env{'form.phase'} eq 'createaccount') { |
if ($env{'form.phase'} eq 'createaccount') { |
my ($result,$output) = &create_account($r,$domain,$lonhost, |
my ($result,$output,$uhome) = |
$data{'username'},$domdesc); |
&create_account($r,$domain,$data{'username'},$domdesc); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$msg = $output; |
$msg = $output; |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
Line 635 sub process_mailtoken {
|
Line 633 sub process_mailtoken {
|
} else { |
} else { |
$msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'}); |
$msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'}); |
} |
} |
&start_session($r, $data{'username'}, $domain, $lonhost, |
&start_session($r,$data{'username'},$domain,$uhome, |
$data{'courseid'}, $token); |
$data{'courseid'},$token); |
$nostart = 1; |
$nostart = 1; |
$noend = 1; |
$noend = 1; |
} else { |
} else { |
Line 663 sub process_mailtoken {
|
Line 661 sub process_mailtoken {
|
} |
} |
|
|
sub start_session { |
sub start_session { |
my ($r, $username, $domain, $lonhost, $courseid, $token) = @_; |
my ($r,$username,$domain,$uhome,$courseid,$token) = @_; |
|
|
if ($r->dir_config('lonBalancer') eq 'yes') { |
if ($r->dir_config('lonBalancer') eq 'yes') { |
Apache::lonauth::success($r, $username, $domain, $lonhost, |
Apache::lonauth::success($r, $username, $domain, $uhome, |
'noredirect', undef, {}); |
'noredirect', undef, {}); |
|
|
Apache::lonnet::tmpdel($token) if $token; |
Apache::lonnet::tmpdel($token) if $token; |
Line 675 sub start_session {
|
Line 673 sub start_session {
|
} else { |
} else { |
$courseid = Apache::lonnet::is_course($courseid); |
$courseid = Apache::lonnet::is_course($courseid); |
|
|
Apache::lonauth::success($r, $username, $domain, $lonhost, |
Apache::lonauth::success($r, $username, $domain, $uhome, |
($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'), |
($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'), |
undef, {}); |
undef, {}); |
} |
} |
Line 809 sub get_creation_controls {
|
Line 807 sub get_creation_controls {
|
} |
} |
|
|
sub create_account { |
sub create_account { |
my ($r,$domain,$lonhost,$username,$domdesc) = @_; |
my ($r,$domain,$username,$domdesc) = @_; |
# Get the token info |
# Get the token info |
my ($retrieved,$output,$upass) = &process_credentials($env{'form.logtoken'}, |
my ($retrieved,$output,$upass) = &process_credentials($env{'form.logtoken'}, |
$env{'form.serverid'}); |
$env{'form.serverid'}); |
Line 849 sub create_account {
|
Line 847 sub create_account {
|
my $uhome = &Apache::lonnet::homeserver($username,$domain); |
my $uhome = &Apache::lonnet::homeserver($username,$domain); |
$output .= '<br />'.&mt('Home server: [_1]',$uhome).' '. |
$output .= '<br />'.&mt('Home server: [_1]',$uhome).' '. |
&Apache::lonnet::hostname($uhome).'<br /><br />'; |
&Apache::lonnet::hostname($uhome).'<br /><br />'; |
return ('ok',$output); |
return ('ok',$output,$uhome); |
} |
} |
|
|
sub username_validation { |
sub username_validation { |
Line 875 sub username_validation {
|
Line 873 sub username_validation {
|
if ($uhome ne 'no_host') { |
if ($uhome ne 'no_host') { |
my $result = &Apache::lonnet::authenticate($username,$upass,$domain); |
my $result = &Apache::lonnet::authenticate($username,$upass,$domain); |
if ($result ne 'no_host') { |
if ($result ne 'no_host') { |
&start_session($r, $username, $domain, $lonhost, $courseid); |
&start_session($r,$username,$domain,$uhome,$courseid); |
$output = '<br /><br />'.&mt('A LON-CAPA account already exists for username [_1] at this institution ([_2]).','<tt>'.$username.'</tt>',$domdesc).'<br />'.&mt('The password entered was also correct so you have been logged in.'); |
$output = '<br /><br />'.&mt('A LON-CAPA account already exists for username [_1] at this institution ([_2]).','<tt>'.$username.'</tt>',$domdesc).'<br />'.&mt('The password entered was also correct so you have been logged in.'); |
return ('existingaccount',$output); |
return ('existingaccount',$output); |
} else { |
} else { |
Line 1029 sub username_check {
|
Line 1027 sub username_check {
|
} |
} |
|
|
sub username_activation { |
sub username_activation { |
my ($r,$username,$domain,$domdesc,$lonhost,$courseid) = @_; |
my ($r,$username,$domain,$domdesc,$courseid) = @_; |
my $output; |
my $output; |
my $error = '<span class="LC_error">'.&mt('Error:').' '; |
my $error = '<span class="LC_error">'.&mt('Error:').' '; |
my $end = '</span><br /><br />'; |
my $end = '</span><br /><br />'; |
Line 1099 sub username_activation {
|
Line 1097 sub username_activation {
|
if ($result eq 'ok') { |
if ($result eq 'ok') { |
my $delete = &Apache::lonnet::tmpdel($env{'form.authtoken'}); |
my $delete = &Apache::lonnet::tmpdel($env{'form.authtoken'}); |
$output = &mt('A LON-CAPA account has been created for username: [_1] in domain: [_2].',$username,$domain); |
$output = &mt('A LON-CAPA account has been created for username: [_1] in domain: [_2].',$username,$domain); |
&start_session($r, $username, $domain, $lonhost, $courseid); |
my $uhome=&Apache::lonnet::homeserver($username,$domain,'true'); |
|
&start_session($r,$username,$domain,$uhome,$courseid); |
my $nostart = 1; |
my $nostart = 1; |
return ('ok',$output,$nostart); |
return ('ok',$output,$nostart); |
} else { |
} else { |