--- loncom/auth/checkauthen.pm 2005/11/29 21:02:50 1.1 +++ loncom/auth/checkauthen.pm 2012/04/18 18:55:06 1.13 @@ -1,7 +1,7 @@ # The LearningOnline Network # checks for a cokkie to authenticate a user # -# $Id: checkauthen.pm,v 1.1 2005/11/29 21:02:50 albertel Exp $ +# $Id: checkauthen.pm,v 1.13 2012/04/18 18:55:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,9 +36,19 @@ use Apache::lonnet; sub handler { my ($r) = @_; + if (&Apache::lonnet::is_domainimage($r->uri)) { + return OK; + } + + if ($r->auth_type() ne 'LONCAPA') { + return DECLINED; + } my $fail = FORBIDDEN; if ($r->dir_config('lonOtherAuthen') eq 'yes') { - &Apache::lonnet::logthis("other authen"); + if (defined($r->dir_config('lonOtherAuthenType'))) { + $r->auth_type($r->dir_config('lonOtherAuthenType')); + } + #&Apache::lonnet::logthis("other authen"); $fail = DECLINED; } @@ -51,18 +61,17 @@ sub handler { } } - my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); - my $lonid=$cookies{'lonID'}; - my $cookie; - if ($lonid) { - my $handle=$lonid->value; - $handle=~s/\W//g; - my $lonidsdir=$r->dir_config('lonIDsDir'); - if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { - return OK; - } + my $handle = &Apache::lonnet::check_for_valid_session($r); + if ($handle eq '') { + $handle = $env{'user.environment'}; } + if ($handle ne '') { + return OK; + } + if (($fail == FORBIDDEN) && ($r->uri eq '/adm/email')) { + $env{'form.firsturl'} = $r->uri; + } return $fail; }