--- loncom/auth/lonauth.pm 1999/12/16 20:30:55 1.3 +++ loncom/auth/lonauth.pm 2000/01/14 21:12:40 1.4 @@ -1,7 +1,8 @@ # The LearningOnline Network # User Authentication Module # 5/21/99,5/22,5/25,5/26,5/27,5/29,6/2,6/11,6/14,6/15 -# 16/11,12/16 Gerd Kortemeyer +# 16/11,12/16, +# 1/14 Gerd Kortemeyer package Apache::lonauth; @@ -14,28 +15,51 @@ use Apache::lonnet(); # ------------------------------------------------------------ Successful login sub success { - my ($r, $lowerurl, $username, $domain, $authhost) = @_; + my ($r, $username, $domain, $authhost) = @_; my $lonids=$r->dir_config('lonIDsDir'); -# See if old ID present, but overlooked + +# See if old ID present, if so, remove my $cookie; - if ($cookie=<$lonids/$username\_*\_$domain\_$authhost.id>) { - $cookie=~s/\.id//; - $cookie=~s/$lonids\///; - } else { + while ($cookie=<$lonids/$username\_*\_$domain\_$authhost.id>) { + unlink($cookie); + } + +# Give them a new cookie + my $now=time; $cookie="$username\_$now\_$domain\_$authhost"; - my $userroles=Apache::lonnet::reply( - "dump:$domain:$username:roles", + my $rolesdump=Apache::lonnet::reply("dump:$domain:$username:roles", $authhost); - $userroles=~s/&/\n/g; + my $userroles=''; + if ($rolesdump ne '') { + map { + my ($area,$role)=split(/=/,$_); + my ($trole,$tend,$tstart)=split(/_/,$role); + if ($tend!=0) { + if ($tend<$now) { + my $localtime=localtime($tend); + $trole="Role expired $localtime"; + } + } + if ($tstart!=0) { + if ($tstart>$now) { + my $localtime=localtime($tend); + $trole="Role becomes active $localtime"; + } + } + if ($area ne '') { + $userroles.="user.role.$area=$trole\n"; + } + } split(/&/,$rolesdump); + } { my $idf=Apache::File->new(">$lonids/$cookie.id"); - print $idf "username=$username\n"; - print $idf "userdomain=$domain\n"; - print $idf "userhome=$authhost\n"; - print $idf "$userroles\n"; + print $idf "user.name=$username\n"; + print $idf "user.domain=$domain\n"; + print $idf "user.home=$authhost\n"; + if ($userroles ne '') { print $idf "$userroles" }; } - } + $cookie="lonID=$cookie; path=/"; $r->send_cgi_header(<print(< -Successful Login to the LearningOnline Network +Successful Login to the LearningOnline Network with CAPA - + ENDSUCCESS @@ -66,12 +90,12 @@ ENDFHEADER $r->print(< -Unsuccessful Login to the LearningOnline Network +Unsuccessful Login to the LearningOnline Network with CAPA

Sorry ...

-

$message to use the LearningOnline Network

+

$message to use the LearningOnline Network with CAPA

ENDFAILED @@ -120,7 +144,7 @@ sub handler { if (!$lonurl) { failed($r,'Cookies need to be activated'); return OK; } my $lowerurl=$lonurl->value; - success($r,$lowerurl,$FORM{'uname'},$FORM{'udom'},$authhost); + success($r,$FORM{'uname'},$FORM{'udom'},$authhost); return OK; }