--- loncom/interface/resetpw.pm 2017/10/02 16:40:18 1.41 +++ loncom/interface/resetpw.pm 2018/12/27 18:14:25 1.42 @@ -1,7 +1,7 @@ # The LearningOnline Network # Allow access to password changing via a token sent to user's e-mail. # -# $Id: resetpw.pm,v 1.41 2017/10/02 16:40:18 raeburn Exp $ +# $Id: resetpw.pm,v 1.42 2018/12/27 18:14:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -412,13 +412,17 @@ sub invalid_state { sub homeserver_redirect { my ($uname,$udom,$domdesc,$brcrum) = @_; - my $uhome = &Apache::lonnet::homeserver(); - if ($uhome eq 'no_host') { + my $uhome; + if ($uname ne '') && ($udom ne '')) { + $uhome = &Apache::lonnet::homeserver($uname,$udom); + } + if (($uhome eq 'no_host') || ($uhome eq '')) { $uhome = &Apache::lonnet::domain($udom,'primary'); } + my $hostname = &Apache::lonnet::hostname($uhome); my $protocol = $Apache::lonnet::protocol{$uhome}; $protocol = 'http' if ($protocol ne 'https'); - my $url = $protocol.'://'.&Apache::lonnet::hostname($uhome).'/adm/resetpw'; + my $url = $protocol.'://'.$hostname.'/adm/resetpw'; # Breadcrumbs my $start_page = &Apache::loncommon::start_page('Switching Server',undef, {'redirect' => [0,$url], @@ -494,10 +498,10 @@ sub reset_passwd { if ($homeserver eq 'no_host') { $r->print(&generic_failure_msg($contact_name,$contact_email)); } else { + my $hostname = &Apache::lonnet::hostname($homeserver); my $protocol = $Apache::lonnet::protocol{$homeserver}; $protocol = 'http' if ($protocol ne 'https'); - my $url = $protocol.'://'.&Apache::lonnet::hostname($homeserver). - '/adm/resetpw'; + my $url = $protocol.'://'.$hostname.'/adm/resetpw'; my ($opentag,$closetag); if ($url) { $opentag = '';