--- loncom/auth/lonauth.pm 2016/02/17 19:15:40 1.139
+++ loncom/auth/lonauth.pm 2017/02/17 14:34:21 1.142
@@ -1,7 +1,7 @@
# The LearningOnline Network
# User Authentication Module
#
-# $Id: lonauth.pm,v 1.139 2016/02/17 19:15:40 raeburn Exp $
+# $Id: lonauth.pm,v 1.142 2017/02/17 14:34:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -29,7 +29,7 @@
package Apache::lonauth;
use strict;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
use Apache::Constants qw(:common);
use CGI qw(:standard);
use DynaLoader; # for Crypt::DES version
@@ -73,7 +73,7 @@ sub success {
}
# ------------------------------------------------------------ Get cookie ready
- $cookie="lonID=$cookie; path=/";
+ $cookie="lonID=$cookie; path=/; HttpOnly";
# -------------------------------------------------------- Menu script and info
my $destination = $lowerurl;
@@ -122,9 +122,30 @@ sub success {
my $header = '';
my $brcrum = [{'href' => '',
'text' => 'Successful Login'},];
+ my $args = {'bread_crumbs' => $brcrum,};
+ unless ((defined($form->{role})) || (defined($form->{symb}))) {
+ my $update=$env{'user.update.time'};
+ if (!$update) {
+ $update = $env{'user.login.time'};
+ }
+ my %roles_in_env;
+ my $showcount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
+ if ($showcount == 1) {
+ foreach my $rolecode (keys(%roles_in_env)) {
+ my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)});
+ if ($cid) {
+ my %coursedescription =
+ &Apache::lonnet::coursedescription($cid,{'one_time' => '1'});
+ if ($coursedescription{'type'} eq 'Placement') {
+ $args->{'crstype'} = 'Placement';
+ }
+ last;
+ }
+ }
+ }
+ }
my $start_page=&Apache::loncommon::start_page('Successful Login',
- $header,
- {'bread_crumbs' => $brcrum,});
+ $header,$args);
my $end_page =&Apache::loncommon::end_page();
my $continuelink=''.&mt('Continue').'';
@@ -228,7 +249,6 @@ sub reroute {
sub handler {
my $r = shift;
my $londocroot = $r->dir_config('lonDocRoot');
- my $form;
# Are we re-routing?
if (-e "$londocroot/lon-status/reroute.txt") {
&reroute($r);
@@ -445,13 +465,25 @@ sub handler {
unless ($hosthere) {
($is_balancer,$otherserver) =
- &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'});
+ &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'},'login');
+ if ($is_balancer) {
+ if ($otherserver eq '') {
+ my $lowest_load;
+ ($otherserver,undef,undef,undef,$lowest_load) = &Apache::lonnet::choose_server($form{'udom'});
+ if ($lowest_load > 100) {
+ $otherserver = &Apache::lonnet::spareserver($lowest_load,$lowest_load,1,$form{'udom'});
+ }
+ }
+ if ($otherserver ne '') {
+ my @hosts = &Apache::lonnet::current_machine_ids();
+ if (grep(/^\Q$otherserver\E$/,@hosts)) {
+ $hosthere = $otherserver;
+ }
+ }
+ }
}
- if ($is_balancer) {
- if (!$otherserver) {
- ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});
- }
+ if (($is_balancer) && (!$hosthere)) {
if ($otherserver) {
&success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
\%form);
@@ -519,6 +551,9 @@ sub handler {
return OK;
}
}
+ if (($is_balancer) && ($hosthere)) {
+ $form{'noloadbalance'} = $hosthere;
+ }
&success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef,
\%form);
return OK;