$lt{'sorry'}
-$message
-$lt{'please'}
-
-$lt{'problems'}
-$end_page
-ENDFAILED
-}
+ $r->print(
+ $start_page
+ .''.&mt('Sorry ...').'
'
+ .''.&mt($message).'
'
+ .''.&mt('Please [_1]log in again[_2].','','')
+ .'
'
+ .''.&mt('Login problems?').'
'
+ .$end_page
+ );
+ }
# ------------------------------------------------------------------ Rerouting!
@@ -151,8 +188,8 @@ sub reroute {
my ($r) = @_;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
- my $msg='Sorry ...
- Please log in again.';
+ my $msg=''.&mt('Sorry ...').'
'
+ .&mt('Please [_1]log in again[_2].');
&Apache::loncommon::simple_error_page($r,'Rerouting',$msg);
}
@@ -179,16 +216,16 @@ sub handler {
&Apache::loncommon::start_page('Already logged in');
my $end_page =
&Apache::loncommon::end_page();
- $r->print(<You are already logged in
-Please either continue the current session or
-logout.
-
-Problems?
-$end_page
-ENDFAILED
- return OK;
+ $r->print(
+ $start_page
+ .''.&mt('You are already logged in!').'
'
+ .''.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'
+ ,'','','','')
+ .'
'
+ .''.&mt('Login problems?').'
'
+ .$end_page
+ );
+ return OK;
}
# ---------------------------------------------------- No valid token, continue
@@ -222,6 +259,7 @@ ENDFAILED
my $role = $r->dir_config('lonRole');
my $domain = $r->dir_config('lonDefDomain');
my $prodir = $r->dir_config('lonUsersDir');
+ my $contact_name = &mt('LON-CAPA helpdesk');
# ---------------------------------------- Get the information from login token
@@ -240,7 +278,25 @@ ENDFAILED
return OK;
}
}
- my ($key,$firsturl)=split(/&/,$tmpinfo);
+
+ if (!&Apache::lonnet::domain($form{'udom'})) {
+ &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);
+ return OK;
+ }
+
+ my ($key,$firsturl,$rolestr,$symbstr)=split(/&/,$tmpinfo);
+ if ($rolestr) {
+ $rolestr = &unescape($rolestr);
+ }
+ if ($symbstr) {
+ $symbstr= &unescape($symbstr);
+ }
+ if ($rolestr =~ /^role=/) {
+ (undef,$form{'role'}) = split('=',$rolestr);
+ }
+ if ($symbstr =~ /^symb=/) {
+ (undef,$form{'symb'}) = split('=',$symbstr);
+ }
my $keybin=pack("H16",$key);
@@ -280,41 +336,35 @@ ENDFAILED
if (grep(/^login$/,@cancreate)) {
$defaultauth = 1;
}
- my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
+ my $uname = $form{'uname'};
+ my $authhost=Apache::lonnet::authenticate($uname,$upass,
$form{'udom'},$defaultauth);
# --------------------------------------------------------------------- Failed?
if ($authhost eq 'no_host') {
- &failed($r,'Username and/or password could not be authenticated.',
- \%form);
- return OK;
- } elsif ($authhost eq 'no_account_on_host') {
- my %domconfig =
- &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
- if (grep(/^login$/,@cancreate)) {
- my $start_page =
- &Apache::loncommon::start_page('Create a user account in LON-CAPA',
- '',{'no_inline_link' => 1,});
- my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');
- my ($output,$checkfail) = &Apache::createaccount::username_check($form{'uname'},
- $form{'udom'},$domdesc);
- &Apache::loncommon::content_type($r,'text/html');
- $r->send_http_header;
- &Apache::createaccount::print_header($r,$start_page);
- my $msg = ''.&mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain.').'
';
- if ($checkfail) {
- $msg .= &mt('A LON-CAPA account may not be created with the username you used.');
- } else {
- $msg .= &mt('To create one, use the table below to provide information about yourself (if appropriate), then click the "Create LON-CAPA account" button.');
- }
- $r->print(''.$msg.'
'.$output);
- $r->print(&Apache::loncommon::end_page());
+ my $lc_uname = lc($form{'uname'});
+ if ($uname eq $lc_uname) {
+ &failed($r,'Username and/or password could not be authenticated.',
+ \%form);
return OK;
} else {
- &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);
- return OK;
+ $authhost=Apache::lonnet::authenticate($lc_uname,$upass,
+ $form{'udom'},$defaultauth);
+ if ($authhost eq 'no_host') {
+ &failed($r,'Username (in lower case) and/or password could not be authenticated.',
+ \%form);
+ return OK;
+ } elsif ($authhost eq 'no_account_on_host') {
+ &create_account($r,\%form,\@cancreate,$lc_uname,$contact_name);
+ return OK;
+ } else {
+ $form{'uname'} = $lc_uname;
+ }
}
+ } elsif ($authhost eq 'no_account_on_host') {
+ &create_account($r,\%form,\@cancreate,$uname);
+ return OK;
}
if (($firsturl eq '') ||
@@ -355,6 +405,38 @@ ENDFAILED
return OK;
}
+sub create_account {
+ my ($r,$form,$cancreate,$uname,$contact_name) = @_;
+ return unless((ref($form) eq 'HASH') && (ref($cancreate) eq 'ARRAY'));
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['usercreation'],$form->{'udom'});
+ if (grep(/^login$/,@{$cancreate})) {
+ my $start_page =
+ &Apache::loncommon::start_page('Create a user account in LON-CAPA',
+ '',{'no_inline_link' => 1,});
+ my $domdesc = &Apache::lonnet::domain($form->{'udom'},'description');
+ my $lonhost = $r->dir_config('lonHostID');
+ my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
+ my $contacts =
+ &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
+ $form->{'udom'},$origmail);
+ my ($contact_email) = split(',',$contacts);
+ my $output =
+ &Apache::createaccount::username_check($uname,$form->{'udom'},
+ $domdesc,'',$lonhost,
+ $contact_email,$contact_name);
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ &Apache::createaccount::print_header($r,$start_page);
+ $r->print(''.&mt('Account creation').'
'.
+ &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'
'.
+ $output.&Apache::loncommon::end_page());
+ } else {
+ &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',$form);
+ }
+ return;
+}
+
1;
__END__