[LON-CAPA-cvs] cvs: loncom /auth migrateuser.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 29 Sep 2007 02:09:50 -0000
albertel Fri Sep 28 22:09:50 2007 EDT
Modified files:
/loncom/auth migrateuser.pm
Log:
- if a user already has a cookie and its associated session file
and they aren't asking for a specific role, then
reuse the existing session info
(redirecting them to either the roles screen or the navmaps screen
(if they are already in a course))
Index: loncom/auth/migrateuser.pm
diff -u loncom/auth/migrateuser.pm:1.10 loncom/auth/migrateuser.pm:1.11
--- loncom/auth/migrateuser.pm:1.10 Fri Jan 12 10:44:27 2007
+++ loncom/auth/migrateuser.pm Fri Sep 28 22:09:50 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Starts a user off based of an existing token.
#
-# $Id: migrateuser.pm,v 1.10 2007/01/12 15:44:27 raeburn Exp $
+# $Id: migrateuser.pm,v 1.11 2007/09/29 02:09:50 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -87,9 +87,30 @@
my $extra_env = &sso_check(\%data);
if (!$data{'role'}) {
- &Apache::lonauth::success($r,$data{'username'},$data{'domain'},
- $home,'/adm/roles',$extra_env);
+ # check for exisiting valid session
+ my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
+ my $lonid=$cookies{'lonID'};
+ my $handle;
+ if ($lonid) {
+ $handle=&LONCAPA::clean_handle($lonid->value);
+ }
+ if ($lonid
+ && -e $r->dir_config('lonIDsDir').'/'.$handle.'.id'
+ && $handle ne '') {
+ &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
+ $handle);
+ if ($env{'request.course.id'}) {
+ $r->internal_redirect('/adm/navmaps');
+ } else {
+ $r->internal_redirect('/adm/roles');
+ }
+ } else {
+ &Apache::lonauth::success($r,$data{'username'},$data{'domain'},
+ $home,'/adm/roles',$extra_env);
+
+ }
return OK;
+
}
my $next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1';