version 1.38, 2016/09/12 16:02:16
|
version 1.41, 2017/10/02 16:40:18
|
Line 96 sub handler {
|
Line 96 sub handler {
|
if ($udom) { |
if ($udom) { |
$domdesc = &Apache::lonnet::domain($udom,'description'); |
$domdesc = &Apache::lonnet::domain($udom,'description'); |
if ($domdesc) { |
if ($domdesc) { |
|
$otherinst = 1; |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
my %servers = &Apache::lonnet::internet_dom_servers($udom); |
my %servers = &Apache::lonnet::internet_dom_servers($udom); |
unless (exists($servers{$server})) { |
foreach my $server (keys(%servers)) { |
$otherinst = 1; |
if (grep(/^\Q$server\E$/,@ids)) { |
|
$otherinst = 0; |
|
last; |
|
} |
} |
} |
} |
} |
} |
} |
Line 196 END
|
Line 201 END
|
'<h2>'.&mt('Reset forgotten LON-CAPA password').'</h2>'; |
'<h2>'.&mt('Reset forgotten LON-CAPA password').'</h2>'; |
my $output; |
my $output; |
if ($token) { |
if ($token) { |
$output = &reset_passwd($r,$token,$contact_name,$contact_email); |
$r->print($header); |
|
&reset_passwd($r,$token,$contact_name,$contact_email); |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
} elsif ($udom) { |
} elsif ($udom) { |
if (!$domdesc) { |
if (!$domdesc) { |
$output = &invalid_state('baddomain',$domdesc, |
$output = &invalid_state('baddomain',$domdesc, |
Line 423 sub homeserver_redirect {
|
Line 431 sub homeserver_redirect {
|
|
|
sub reset_passwd { |
sub reset_passwd { |
my ($r,$token,$contact_name,$contact_email) = @_; |
my ($r,$token,$contact_name,$contact_email) = @_; |
my $msg; |
|
my %data = &Apache::lonnet::tmpget($token); |
my %data = &Apache::lonnet::tmpget($token); |
my $now = time; |
my $now = time; |
if (keys(%data) == 0) { |
if (keys(%data) == 0) { |
$msg = &mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.' |
$r->print(&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.' |
,'<a href="/adm/resetpw">','</a>'); |
,'<a href="/adm/resetpw">','</a>') |
return $msg; |
); |
|
return; |
} |
} |
if (($data{'time'} =~ /^\d+$/) && |
if (($data{'time'} =~ /^\d+$/) && |
($data{'username'} ne '') && |
($data{'username'} ne '') && |
Line 440 sub reset_passwd {
|
Line 448 sub reset_passwd {
|
my ($blocked,$blocktext) = |
my ($blocked,$blocktext) = |
&Apache::loncommon::blocking_status('passwd',$data{'username'},$data{'domain'}); |
&Apache::loncommon::blocking_status('passwd',$data{'username'},$data{'domain'}); |
if ($blocked) { |
if ($blocked) { |
$msg = '<p class="LC_warning">'.$blocktext.'</p>'; |
$r->print('<p class="LC_warning">'.$blocktext.'</p>'); |
return $msg; |
return; |
} elsif ($now - $data{'time'} < 7200) { |
} elsif ($now - $data{'time'} < 7200) { |
if ($env{'form.action'} eq 'verify_and_change_pass') { |
if ($env{'form.action'} eq 'verify_and_change_pass') { |
|
$env{'form.uname'} =~ s/^\s+|\s+$//g; |
|
$env{'form.udom'} =~ s/^\s+|\s+$//g; |
|
$env{'form.email'} =~ s/^\s+|\s+$//g; |
unless (($env{'form.uname'} eq $data{'username'}) && ($env{'form.udom'} eq $data{'domain'}) && ($env{'form.email'} eq $data{'email'})) { |
unless (($env{'form.uname'} eq $data{'username'}) && ($env{'form.udom'} eq $data{'domain'}) && ($env{'form.email'} eq $data{'email'})) { |
$msg = &generic_failure_msg($contact_name,$contact_email); |
&Apache::lonnet::logthis("Forgot Password -- token data: ||$data{'username'}|| ||$data{'domain'}|| ||$data{'email'}|| differs from form: ||$env{'form.uname'}|| ||$env{'form.udom'}|| ||$env{'form.email'}||"); |
return $msg; |
$r->print(&generic_failure_msg($contact_name,$contact_email)); |
|
return; |
} |
} |
my $change_failed = |
my $change_failed = |
&Apache::lonpreferences::verify_and_change_password($r,'reset_by_email',$token); |
&Apache::lonpreferences::verify_and_change_password($r,'reset_by_email',$token); |
Line 472 sub reset_passwd {
|
Line 484 sub reset_passwd {
|
.' confirming setting of your new password.' |
.' confirming setting of your new password.' |
,'<span class="LC_filename">'.$data{'email'}.'</span>'),1); |
,'<span class="LC_filename">'.$data{'email'}.'</span>'),1); |
} |
} |
$msg .= |
$r->print( |
&Apache::loncommon::confirmwrapper($confirm_msg) |
&Apache::loncommon::confirmwrapper($confirm_msg) |
.&Apache::lonhtmlcommon::actionbox([ |
.&Apache::lonhtmlcommon::actionbox([ |
'<a href="/adm/login">'.&mt('Go to the login page').'</a>']); |
'<a href="/adm/login">'.&mt('Go to the login page').'</a>']) |
|
); |
} elsif ($change_failed eq 'invalid_client') { |
} elsif ($change_failed eq 'invalid_client') { |
my $homeserver = &Apache::lonnet::homeserver($data{'username'},$data{'domain'}); |
my $homeserver = &Apache::lonnet::homeserver($data{'username'},$data{'domain'}); |
if ($homeserver eq 'no_host') { |
if ($homeserver eq 'no_host') { |
$msg .= &generic_failure_msg($contact_name,$contact_email); |
$r->print(&generic_failure_msg($contact_name,$contact_email)); |
} else { |
} else { |
my $protocol = $Apache::lonnet::protocol{$homeserver}; |
my $protocol = $Apache::lonnet::protocol{$homeserver}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
Line 490 sub reset_passwd {
|
Line 503 sub reset_passwd {
|
$opentag = '<a href="'.$url.'">'; |
$opentag = '<a href="'.$url.'">'; |
$closetag = '</a>'; |
$closetag = '</a>'; |
} |
} |
$msg .= |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&mt('A problem occurred when attempting to reset' |
.&mt('A problem occurred when attempting to reset' |
.' the password for your account.' |
.' the password for your account.' |
.' Please try again from your [_1]home server[_2].' |
.' Please try again from your [_1]home server[_2].' |
,$opentag,$closetag) |
,$opentag,$closetag) |
.'</p>'; |
.'</p>' |
|
); |
} |
} |
} else { |
} else { |
$msg .= &generic_failure_msg($contact_name,$contact_email); |
$r->print(&generic_failure_msg($contact_name,$contact_email)); |
} |
} |
} else { |
} else { |
$r->print(&mt('The token included in an e-mail sent to you [_1] has been verified, so you may now proceed to reset the password for your LON-CAPA account.',$reqtime).'<br /><br />'); |
$r->print(&mt('The token included in an e-mail sent to you [_1] has been verified, so you may now proceed to reset the password for your LON-CAPA account.',$reqtime).'<br /><br />'); |
Line 507 sub reset_passwd {
|
Line 521 sub reset_passwd {
|
&Apache::lonpreferences::passwordchanger($r,'','reset_by_email',$token); |
&Apache::lonpreferences::passwordchanger($r,'','reset_by_email',$token); |
} |
} |
} else { |
} else { |
$msg = |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&mt('Sorry, the token generated when you requested a password reset has expired. Please submit a [_1]new request[_2], and follow the link to the web page included in the new e-mail that will be sent to you, to allow you to enter a new password.' |
.&mt('Sorry, the token generated when you requested a password reset has expired. Please submit a [_1]new request[_2], and follow the link to the web page included in the new e-mail that will be sent to you, to allow you to enter a new password.' |
,'<a href="/adm/resetpw">','</a>') |
,'<a href="/adm/resetpw">','</a>') |
.'</p>'; |
.'</p>' |
|
); |
} |
} |
} else { |
} else { |
$msg .= |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&mt('Sorry, the URL generated when you requested reset of your password contained incomplete information. Please submit a [_1]new request[_2] for a password reset, and use the new URL that will be sent to your e-mail account to complete the process.' |
.&mt('Sorry, the URL generated when you requested reset of your password contained incomplete information. Please submit a [_1]new request[_2] for a password reset, and use the new URL that will be sent to your e-mail account to complete the process.' |
,'<a href="/adm/resetpw">','</a>') |
,'<a href="/adm/resetpw">','</a>') |
.'</p>'; |
.'</p>' |
|
); |
} |
} |
return $msg; |
return; |
} |
} |
|
|
sub generic_failure_msg { |
sub generic_failure_msg { |