# The LearningOnline Network # Starts a user off based of an existing token. # # $Id: migrateuser.pm,v 1.2 2005/10/25 19:14:32 albertel Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # package Apache::migrateuser; use strict; use Apache::Constants qw(:common :http :methods); use Apache::lonauth; use Apache::lonnet; sub goto_login { my ($r) = @_; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; $r->print(< Going to login

One moment please...

Transferring to login page. Continue

TOLOGIN return OK; } sub handler { my ($r) = @_; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token']); my %data = &Apache::lonnet::tmpget($env{'form.token'}); if ($data{'ip'} ne $ENV{'REMOTE_ADDR'} || !defined($data{'username'}) || !defined($data{'domain'}) ) { return &goto_login($r); } &Apache::lonnet::logthis("Allowing access for $data{'username'}\@$data{'domain'} to $data{'role'}"); my $home=&Apache::lonnet::homeserver($data{'username'},$data{'domain'}); if ($home =~ /(con_lost|no_such_host)/) { return &goto_login($r); } if (!defined($data{'role'})) { &Apache::lonauth::success($r,$data{'username'},$data{'domain'}, $home,'/adm/roles'); return OK; } my $cookie=&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, $home,'noredirect'); $r->header_out('Set-cookie',"lonID=$cookie; path=/"); &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), $cookie); $env{'form.selectrole'}='1'; $env{'form.'.$data{'role'}}='1'; return &Apache::lonroles::handler($r); } 1; __END__