version 1.47, 2020/02/09 04:43:20
|
version 1.51, 2021/11/30 16:08:44
|
Line 115 sub handler {
|
Line 115 sub handler {
|
} |
} |
} |
} |
my %passwdconf = &Apache::lonnet::get_passwdconf($dom_in_effect); |
my %passwdconf = &Apache::lonnet::get_passwdconf($dom_in_effect); |
|
my $clientip = &Apache::lonnet::get_requestor_ip($r); |
my $token = $env{'form.token'}; |
my $token = $env{'form.token'}; |
my $useremail = $env{'form.useremail'}; |
my $useremail = $env{'form.useremail'}; |
if (($udom ne '') && (!$otherinst) && (!$token)) { |
if (($udom ne '') && (!$otherinst) && (!$token)) { |
Line 292 END
|
Line 293 END
|
my $output; |
my $output; |
if ($token) { |
if ($token) { |
$r->print($header); |
$r->print($header); |
&reset_passwd($r,$token,$contact_name,$contact_email,\%passwdconf); |
&reset_passwd($r,$token,$contact_name,$contact_email,$clientip,\%passwdconf); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} elsif ($udom) { |
} elsif ($udom) { |
Line 300 END
|
Line 301 END
|
$output = &invalid_state('baddomain',$domdesc, |
$output = &invalid_state('baddomain',$domdesc, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
} elsif ($otherinst) { |
} elsif ($otherinst) { |
($header,$output) = &homeserver_redirect($uname,$udom,$domdesc,$brcrum); |
($header,$output) = &homeserver_redirect($r,$uname,$udom,$domdesc,$brcrum); |
} elsif (($uname) || ($useremail)) { |
} elsif (($uname) || ($useremail)) { |
my $earlyout; |
my $earlyout; |
unless ($passwdconf{'captcha'} eq 'unused') { |
unless ($passwdconf{'captcha'} eq 'unused') { |
Line 327 END
|
Line 328 END
|
my $authtype = &Apache::lonnet::queryauthenticate($uname,$udom); |
my $authtype = &Apache::lonnet::queryauthenticate($uname,$udom); |
if ($authtype =~ /^internal/) { |
if ($authtype =~ /^internal/) { |
my ($blocked,$blocktext) = |
my ($blocked,$blocktext) = |
&Apache::loncommon::blocking_status('passwd',$uname,$udom); |
&Apache::loncommon::blocking_status('passwd',$clientip,$uname,$udom); |
if ($blocked) { |
if ($blocked) { |
$output = '<p class="LC_warning">'.$blocktext.'</p>' |
$output = '<p class="LC_warning">'.$blocktext.'</p>' |
.&display_actions($contact_email,$domdesc); |
.&display_actions($contact_email,$domdesc); |
Line 482 sub send_token {
|
Line 483 sub send_token {
|
|
|
my $now = time; |
my $now = time; |
my $temppasswd = &create_passwd(); |
my $temppasswd = &create_passwd(); |
my %info = ('ip' => $ENV{'REMOTE_ADDR'}, |
my $ip = &Apache::lonnet::get_requestor_ip(); |
|
my %info = ('ip' => $ip, |
'time' => $now, |
'time' => $now, |
'domain' => $udom, |
'domain' => $udom, |
'username' => $uname, |
'username' => $uname, |
Line 578 sub invalid_state {
|
Line 580 sub invalid_state {
|
} |
} |
|
|
sub homeserver_redirect { |
sub homeserver_redirect { |
my ($uname,$udom,$domdesc,$brcrum) = @_; |
my ($r,$uname,$udom,$domdesc,$brcrum) = @_; |
my $uhome; |
my $uhome; |
if (($uname ne '') && ($udom ne '')) { |
if (($uname ne '') && ($udom ne '')) { |
$uhome = &Apache::lonnet::homeserver($uname,$udom); |
$uhome = &Apache::lonnet::homeserver($uname,$udom); |
Line 589 sub homeserver_redirect {
|
Line 591 sub homeserver_redirect {
|
my $hostname = &Apache::lonnet::hostname($uhome); |
my $hostname = &Apache::lonnet::hostname($uhome); |
my $protocol = $Apache::lonnet::protocol{$uhome}; |
my $protocol = $Apache::lonnet::protocol{$uhome}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
|
my $alias = &Apache::lonnet::use_proxy_alias($r,$uhome); |
|
$hostname = $alias if ($alias ne ''); |
my $url = $protocol.'://'.$hostname.'/adm/resetpw'; |
my $url = $protocol.'://'.$hostname.'/adm/resetpw'; |
# Breadcrumbs |
# Breadcrumbs |
my $start_page = &Apache::loncommon::start_page('Switching Server',undef, |
my $start_page = &Apache::loncommon::start_page('Switching Server',undef, |
Line 601 sub homeserver_redirect {
|
Line 605 sub homeserver_redirect {
|
} |
} |
|
|
sub reset_passwd { |
sub reset_passwd { |
my ($r,$token,$contact_name,$contact_email,$passwdconf) = @_; |
my ($r,$token,$contact_name,$contact_email,$clientip,$passwdconf) = @_; |
return unless (ref($passwdconf) eq 'HASH'); |
return unless (ref($passwdconf) eq 'HASH'); |
my %data = &Apache::lonnet::tmpget($token); |
my %data = &Apache::lonnet::tmpget($token); |
my $now = time; |
my $now = time; |
Line 622 sub reset_passwd {
|
Line 626 sub reset_passwd {
|
} |
} |
my $reqtime = &Apache::lonlocal::locallocaltime($data{'time'}); |
my $reqtime = &Apache::lonlocal::locallocaltime($data{'time'}); |
my ($blocked,$blocktext) = |
my ($blocked,$blocktext) = |
&Apache::loncommon::blocking_status('passwd',$data{'username'},$data{'domain'}); |
&Apache::loncommon::blocking_status('passwd',$clientip,$data{'username'},$data{'domain'}); |
if ($blocked) { |
if ($blocked) { |
$r->print('<p class="LC_warning">'.$blocktext.'</p>'); |
$r->print('<p class="LC_warning">'.$blocktext.'</p>'); |
return; |
return; |
Line 723 sub reset_passwd {
|
Line 727 sub reset_passwd {
|
my $now = &Apache::lonlocal::locallocaltime(time); |
my $now = &Apache::lonlocal::locallocaltime(time); |
my $domdesc = |
my $domdesc = |
&Apache::lonnet::domain($data{'domain'},'description'); |
&Apache::lonnet::domain($data{'domain'},'description'); |
my $mailmsg = &mt('The password for your LON-CAPA account in the [_1] domain was changed [_2] from IP address: [_3]. If you did not perform this change or authorize it, please contact the [_4] ([_5]).',$domdesc,$now,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n"; |
my $ip = &Apache::lonnet::get_requestor_ip(); |
|
my $mailmsg = &mt('The password for your LON-CAPA account in the [_1] domain was changed [_2] from IP address: [_3]. If you did not perform this change or authorize it, please contact the [_4] ([_5]).',$domdesc,$now,$ip,$contact_name,$contact_email)."\n"; |
my $result = &send_mail($domdesc,$data{'email'},$mailmsg, |
my $result = &send_mail($domdesc,$data{'email'},$mailmsg, |
$contact_name,$contact_email); |
$contact_name,$contact_email); |
my $confirm_msg; |
my $confirm_msg; |
Line 753 sub reset_passwd {
|
Line 758 sub reset_passwd {
|
my $hostname = &Apache::lonnet::hostname($homeserver); |
my $hostname = &Apache::lonnet::hostname($homeserver); |
my $protocol = $Apache::lonnet::protocol{$homeserver}; |
my $protocol = $Apache::lonnet::protocol{$homeserver}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
|
my $alias = &Apache::lonnet::use_proxy_alias($r,$homeserver); |
|
$hostname = $alias if ($alias ne ''); |
my $url = $protocol.'://'.$hostname.'/adm/resetpw'; |
my $url = $protocol.'://'.$hostname.'/adm/resetpw'; |
my ($opentag,$closetag); |
my ($opentag,$closetag); |
if ($url) { |
if ($url) { |