Annotation of loncom/auth/migrateuser.pm, revision 1.1
1.1 ! albertel 1: # The LearningOnline Network
! 2: # Starts a user off based of an existing token.
! 3: #
! 4: # $Id: lonlogout.pm,v 1.15 2005/09/20 07:33:54 albertel Exp $
! 5: #
! 6: # Copyright Michigan State University Board of Trustees
! 7: #
! 8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
! 9: #
! 10: # LON-CAPA is free software; you can redistribute it and/or modify
! 11: # it under the terms of the GNU General Public License as published by
! 12: # the Free Software Foundation; either version 2 of the License, or
! 13: # (at your option) any later version.
! 14: #
! 15: # LON-CAPA is distributed in the hope that it will be useful,
! 16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
! 17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 18: # GNU General Public License for more details.
! 19: #
! 20: # You should have received a copy of the GNU General Public License
! 21: # along with LON-CAPA; if not, write to the Free Software
! 22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! 23: #
! 24: # /home/httpd/html/adm/gpl.txt
! 25: #
! 26: # http://www.lon-capa.org/
! 27: #
! 28:
! 29: package Apache::startuser;
! 30:
! 31: use strict;
! 32: use Apache::Constants qw(:common :http :methods);
! 33: use Apache::lonauth;
! 34: use Apache::lonnet;
! 35:
! 36: sub goto_login {
! 37: my ($r) = @_;
! 38: &Apache::loncommon::content_type($r,'text/html');
! 39: $r->send_http_header;
! 40: $r->print(<<TOLOGIN);
! 41: <html>
! 42: <head>
! 43: <meta http-equiv="refresh" content="10;url=/adm/login" />
! 44: <title>Going to login</title>
! 45: </head>
! 46: <body>
! 47: <h1>One moment please...</h1>
! 48: <p>
! 49: Transferring to login page.
! 50: <a href="/adm/login">Continue</a>
! 51: </p>
! 52: </body>
! 53: </html>
! 54: TOLOGIN
! 55: return '';
! 56: }
! 57:
! 58: sub handler {
! 59: my ($r) = @_;
! 60:
! 61: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token']);
! 62: my $data = &Apache::lonnet::reply('tmpget:'.$env{'form.token'},
! 63: $Apache::lonnet::perlvar{'lonHostID'});
! 64: my ($ip,$udom,$uname,$role) = split('&',$data);
! 65:
! 66: if ($ip ne $ENV{'REMOTE_ADDR'} && $ip ne '127.0.0.1') {
! 67: #error or invalid token
! 68: &goto_login($r);
! 69: return OK;
! 70: }
! 71:
! 72: &Apache::lonnet::logthis("Allowing access for $uname\@$udom to $role");
! 73: my $home=&Apache::lonnet::homeserver($uname,$udom);
! 74: my $cookie=&Apache::lonauth::success($r,$uname,$udom,$home,'noredirect');
! 75: $r->header_out('Set-cookie',"lonID=$cookie; path=/");
! 76: &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
! 77: $cookie);
! 78: $env{'form.selectrole'}='1';
! 79: $env{'form.'.$role}='1';
! 80: return &Apache::lonroles::handler($r);
! 81: }
! 82:
! 83: 1;
! 84: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>