--- loncom/auth/lonauth.pm 2018/07/01 00:03:42 1.153 +++ loncom/auth/lonauth.pm 2018/11/10 10:53:01 1.155 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.153 2018/07/01 00:03:42 raeburn Exp $ +# $Id: lonauth.pm,v 1.155 2018/11/10 10:53:01 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,8 +76,9 @@ sub success { # ----------------------------------------------------------- Get cookies ready my ($securecookie,$defaultcookie); - if ($ENV{'SERVER_PORT'} == 443) { - $securecookie="lonID=$cookie; path=/; HttpOnly; secure"; + my $ssl = $r->subprocess_env('https'); + if ($ssl) { + $securecookie="lonSID=$cookie; path=/; HttpOnly; secure"; my $lonidsdir=$r->dir_config('lonIDsDir'); if (($lonidsdir) && (-e "$lonidsdir/$cookie.id")) { my $linkname=substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, 32).'_linked'; @@ -88,7 +89,7 @@ sub success { "$lonidsdir/$linkname.id"); 1 }; if ($made_symlink) { $defaultcookie = "lonLinkID=$linkname; path=/; HttpOnly;"; - &Apache::lonnet::appenv({'user.linkedenv' => "$lonidsdir/$linkname.id"}); + &Apache::lonnet::appenv({'user.linkedenv' => $linkname}); } } } else { @@ -297,6 +298,12 @@ sub failed { $retry .= (($retry=~/\?/)?'&':'?').'symb='.$symb; } } + if (exists($form->{firsturl})) { + my $firsturl = &Apache::loncommon::cleanup_html($form->{firsturl}); + if ($firsturl ne '') { + $retry .= (($retry=~/\?/)?'&':'?').'firsturl='.$firsturl; + } + } my $end_page = &Apache::loncommon::end_page(); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -441,6 +448,9 @@ sub handler { if ($iptokenstr) { $iptokenstr = &unescape($iptokenstr); } + if ($firsturl =~ m{^/tiny/$match_domain/\w+$}) { + $form{'firsturl'} = $firsturl; + } if ($rolestr =~ /^role=/) { (undef,$form{'role'}) = split('=',$rolestr); }