'
.&mt('Username and/or password could not be authenticated.')
@@ -697,8 +746,10 @@ sub username_validation {
}
sub username_check {
- my ($username,$domain,$domdesc,$courseid) = @_;
- my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
+ my ($username,$domain,$domdesc,$courseid,$lonhost,$contact_email,$contact_name,
+ $sso_logout) = @_;
+ my (%rulematch,%inst_results,$newuser,$checkfail,$rowcount,$editable,$output,$msg,
+ %alerts,%curr_rules,%got_rules);
$newuser = 1;
my $checkhash;
my $checks = { 'username' => 1 };
@@ -708,45 +759,107 @@ sub username_check {
if (ref($alerts{'username'}) eq 'HASH') {
if (ref($alerts{'username'}{$domain}) eq 'HASH') {
if ($alerts{'username'}{$domain}{$username}) {
- my ($userchkmsg,$checkfail);
if (ref($curr_rules{$domain}) eq 'HASH') {
- $userchkmsg =
- &Apache::loncommon::instrule_disallow_msg('username',$domdesc,1).
+ $output =
+ &Apache::loncommon::instrule_disallow_msg('username',$domdesc,1,
+ 'selfcreate').
&Apache::loncommon::user_rule_formats($domain,$domdesc,
$curr_rules{$domain}{'username'},'username');
- if ($userchkmsg) {
- $checkfail = 1;
- }
}
- return ($userchkmsg,$checkfail);
+ $checkfail = 'username';
}
}
}
- my $submit_text = &mt('Create LON-CAPA account');
- # FIXME need a cookie to confirm credentials were validated.
- my $output = '
';
- return ($output,'');
+ if (!$checkfail) {
+ $output = '
';
+ if ($rowcount) {
+ if ($editable) {
+ $msg = &mt('To create one, use the table below to provide information about yourself, then click the [_1]Create LON-CAPA account[_2] button.','
','').'
';
+ } else {
+ $msg = &mt('A user account will be created with information displayed in the table below, when you click the [_1]Create LON-CAPA account[_2] button.','
','').'
';
+ }
+ } else {
+ $msg = '
'.&mt('Confirm that you wish to create an account.');
+ }
+ $msg .= $output;
+ }
+ return $msg;
}
sub username_activation {
my ($r,$username,$domain,$domdesc,$lonhost,$courseid) = @_;
my $output;
- my $error = '
'.&mt('Error').': ';
+ my $error = ''.&mt('Error:').' ';
my $end = '
';
my $rtnlink = ''.
&mt('Return to previous page').''.
&Apache::loncommon::end_page();
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
+ my %data = &Apache::lonnet::tmpget($env{'form.authtoken'});
+ my $now = time;
+ my $earlyout;
+ my $timeout = 300;
+ if (keys(%data) == 0) {
+ $output = &mt('Sorry, your authentication has expired.');
+ $earlyout = 'fail';
+ }
+ if (($data{'time'} !~ /^\d+$/) ||
+ ($data{'domain'} ne $domain) ||
+ ($data{'username'} ne $username)) {
+ $earlyout = 'fail';
+ $output = &mt('The credentials you provided could not be verified.');
+ } elsif ($now - $data{'time'} > $timeout) {
+ $earlyout = 'fail';
+ $output = &mt('Sorry, your authentication has expired.');
+ }
+ if ($earlyout ne '') {
+ $output .= '
'.&mt('Please [_1]start again[_2].','','');
+ return($earlyout,$output);
+ }
if ((($domdefaults{'auth_def'} =~/^krb(4|5)$/) &&
($domdefaults{'auth_arg_def'} ne '')) ||
($domdefaults{'auth_def'} eq 'localauth')) {
@@ -767,6 +880,7 @@ sub username_activation {
$env{'form.cgeneration'},undef,undef,
$env{'form.cpermanentemail'});
if ($result eq 'ok') {
+ 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);
my %form = &start_session($r,$username,$domain,$lonhost,$courseid);
my $nostart = 1;
@@ -776,7 +890,7 @@ sub username_activation {
return ('fail',$output);
}
} else {
- $output = &mt("User account creation is not available for the current default authentication type.\n");
+ $output = &mt('User account creation is not available for the current default authentication type.')."\n";
return('fail',$output);
}
}
@@ -812,28 +926,36 @@ sub check_id {
sub invalid_state {
my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_;
- my $msg;
+ my $msg = ''.&mt('Account creation unavailable').'
';
if ($error eq 'baduseremail') {
$msg = &mt('The e-mail address you provided does not appear to be a valid address.');
} elsif ($error eq 'existinguser') {
- $msg = &mt('The e-mail address you provided is already in use as a username in this LON-CAPA domain.');
+ $msg = &mt('The e-mail address you provided is already in use as a username in LON-CAPA at this institution.');
} elsif ($error eq 'userrules') {
- $msg = &mt('Username rules for this LON-CAPA domain do not allow the e-mail address you provided to be used as a username.');
+ $msg = &mt('Username rules for this LON-CAPA at this institution do not allow the e-mail address you provided to be used as a username.');
} elsif ($error eq 'userformat') {
- $msg = &mt('The e-mail address you provided may not be used as a username in this LON-CAPA domain.');
+ $msg = &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.');
} elsif ($error eq 'captcha') {
$msg = &mt('Validation of the code your entered failed.');
} elsif ($error eq 'noemails') {
- $msg = &mt('Creation of a new user account using an e-mail address as username is not permitted in this LON-CAPA domain.');
+ $msg = &mt('Creation of a new user account using an e-mail address as username is not permitted at this LON-CAPA institution.');
}
+ $msg .= '';
if ($msgtext) {
$msg .= '
'.$msgtext;
}
+ $msg .= &linkto_email_help($contact_email,$domdesc);
+ return $msg;
+}
+
+sub linkto_email_help {
+ my ($contact_email,$domdesc) = @_;
+ my $msg;
if ($contact_email ne '') {
my $escuri = &HTML::Entities::encode('/adm/createaccount','&<>"');
- $msg .= '
'.&mt(' You may wish to contact the LON-CAPA helpdesk for the [_2] domain.',$escuri,$domdesc);
+ $msg .= '
'.&mt('You may wish to contact the [_1]LON-CAPA helpdesk[_2] for [_3].','','',$domdesc).'
';
} else {
- $msg .= '
'.&mt(' You may wish to send an e-mail to the server administrator: [_1] for the [_2] domain.',$Apache::lonnet::perlvar{'AdminEmail'},$domdesc);
+ $msg .= '
'.&mt('You may wish to send an e-mail to the server administrator: [_1] for [_2].',$Apache::lonnet::perlvar{'AdminEmail'},$domdesc).'
';
}
return $msg;
}
@@ -855,9 +977,9 @@ sub create_captcha {
sub captcha_settings {
my %captcha_params = (
- output_dir => "/home/httpd/html/captcha",
- www_output_dir => "/captcha",
- db_dir => "/home/www/captchadb",
+ output_dir => $Apache::lonnet::perlvar{'lonCaptchaDir'},
+ www_output_dir => "/captchaspool",
+ db_dir => $Apache::lonnet::perlvar{'lonCaptchaDb'},
numchars => '5',
);
return %captcha_params;
@@ -894,7 +1016,8 @@ sub process_credentials {
my $tmpinfo=Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
my ($retrieved,$output,$upass);
if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
- $output = &mt('Information needed to retrieve your log-in information is missing, inaccessible or expired.').'
'.&mt('You may need to reload the previous page to obtain a new token.');
+ $output = &mt('Information needed to verify your login information is missing, inaccessible or expired.')
+ .'
'.&mt('You may need to reload the previous page to obtain a new token.');
return ($retrieved,$output,$upass);
} else {
my $reply = &Apache::lonnet::reply('tmpdel:'.$logtoken,$lonhost);
@@ -939,11 +1062,32 @@ sub guest_format_check {
$format_msg = '
'.&mt("Your e-mail address uses the same internet domain as your institution's LON-CAPA service.").'
'.&mt('Creation of a LON-CAPA account with this type of e-mail address as username is not permitted.').'
';
if (ref($cancreate) eq 'ARRAY') {
if (grep(/^login$/,@{$cancreate})) {
- $format_msg .= &mt('You should request creation of a LON-CAPA account for a Log-in ID of "[_1]" at your institution instead.',$login).'
';
+ $format_msg .= &mt('You should request creation of a LON-CAPA account for a log-in ID of "[_1]" at your institution instead.',$login).'
';
}
}
}
return $format_msg;
}
+sub sso_logout_frag {
+ my ($r,$domain) = @_;
+ my $endsessionmsg;
+ if (defined($r->dir_config('lonSSOUserLogoutMessageFile_'.$domain))) {
+ my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile_'.$domain);
+ if (-e $msgfile) {
+ open(my $fh,"<$msgfile");
+ $endsessionmsg = join('',<$fh>);
+ close($fh);
+ }
+ } elsif (defined($r->dir_config('lonSSOUserLogoutMessageFile'))) {
+ my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile');
+ if (-e $msgfile) {
+ open(my $fh,"<$msgfile");
+ $endsessionmsg = join('',<$fh>);
+ close($fh);
+ }
+ }
+ return $endsessionmsg;
+}
+
1;