MDL-22631 Added some clean_param calls to clean the $_GET data and also added lots...
[moodle.git] / auth / mnet / land.php
blobe59cc4527ea49ee2af86960727d5b6627187352d
1 <?php
3 /**
4 * @author Martin Dougiamas
5 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
6 * @package moodle multiauth
8 * Authentication Plugin: Moodle Network Authentication
10 * Multiple host authentication support for Moodle Network.
12 * 2006-11-01 File created.
15 require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
16 require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
18 if (!$site = get_site()) {
19 print_error('mnet_session_prohibited', 'mnet', '', '');
22 if (!is_enabled_auth('mnet')) {
23 error('mnet is disabled');
25 // grab the GET params
26 $token = required_param('token', PARAM_BASE64);
27 $remotewwwroot = required_param('idp', PARAM_URL);
28 $wantsurl = required_param('wantsurl', PARAM_LOCALURL);
30 // confirm the MNET session
31 $mnetauth = get_auth_plugin('mnet');
32 $localuser = $mnetauth->confirm_mnet_session($token, $remotewwwroot);
34 // log in
35 $USER = get_complete_user_data('id', $localuser->id, $localuser->mnethostid);
36 complete_user_login($USER);
37 $mnetauth->update_session_id();
39 if (!empty($localuser->mnet_foreign_host_array)) {
40 $USER->mnet_foreign_host_array = $localuser->mnet_foreign_host_array;
43 // redirect
44 redirect($CFG->wwwroot . $wantsurl);