--- loncom/auth/lonauth.pm 2009/07/03 10:22:00 1.99 +++ loncom/auth/lonauth.pm 2009/07/22 20:24:07 1.100 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.99 2009/07/03 10:22:00 bisitz Exp $ +# $Id: lonauth.pm,v 1.100 2009/07/22 20:24:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -73,8 +73,44 @@ sub success { # ------------------------------------------------------------ Get cookie ready $cookie="lonID=$cookie; path=/"; # -------------------------------------------------------- Menu script and info + my $destination = $lowerurl; + + if (defined($form->{role})) { + my $envkey = 'user.role.'.$form->{role}; + my $now=time; + my $then=$env{'user.login.time'}; + my $refresh=$env{'user.refresh.time'}; + if (exists($env{$envkey})) { + my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus); + &Apache::lonnet::role_status($envkey,$then,$refresh,$now,\$role,\$where, + \$trolecode,\$tstatus,\$tstart,\$tend); + if ($tstatus eq 'is') { + if ($destination =~ /\?/) { + $destination .= '&'; + } else { + $destination .= '?'; + } + $destination .= 'selectrole=1&'.$form->{role}.'=1'; + if (defined($form->{symb})) { + my $destsymb = $form->{symb}; + if ($destsymb =~ /___/) { + # FIXME Need to deal with encrypted symbs and urls as needed. + my ($map,$resid,$desturl)=split(/___/,$destsymb); + unless ($desturl=~/^(adm|uploaded|editupload|public)/) { + $desturl = &Apache::lonnet::clutter($desturl); + } + $destination .= '&destinationurl='.$desturl. + '&destsymb='.$destsymb; + } else { + $destination .= '&destinationurl='.$destsymb; + } + } + } + } + } + my $windowinfo=&Apache::lonmenu::open($env{'browser.os'}); - my $startupremote=&Apache::lonmenu::startupremote($lowerurl); + my $startupremote=&Apache::lonmenu::startupremote($destination); my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl); my $setflags=&Apache::lonmenu::setflags(); my $maincall=&Apache::lonmenu::maincall(); @@ -88,7 +124,7 @@ sub success { my $continuelink; if ($env{'environment.remote'} eq 'off') { - $continuelink="".&mt('Continue').""; + $continuelink=''.&mt('Continue').''; } # ------------------------------------------------- Output for successful login @@ -122,6 +158,14 @@ sub failed { my ($r,$message,$form) = @_; my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef, {'no_inline_link' => 1,}); + my $retry = '/adm/login?username='.$form->{'uname'}. + '&domain='.$form->{'udom'}; + if (exists($form->{role})) { + $retry .= '&role='.$form->{role}; + } + if (exists($form->{symb})) { + $retry .= '&symb='.$form->{symb}; + } my $end_page = &Apache::loncommon::end_page(); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -129,8 +173,7 @@ sub failed { $start_page .'

'.&mt('Sorry ...').'

' .'

'.&mt($message).'

' - .'

'.&mt('Please [_1]log in again[_2].' - ,"{'uname'}&domain=$form->{'udom'}\">",'') + .'

'.&mt('Please [_1]log in again[_2].','','') .'

' .'

'.&mt('Login problems?').'

' .$end_page @@ -233,11 +276,25 @@ sub handler { return OK; } } + 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)=split(/&/,$tmpinfo); + + 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);