From: jerome Date: Fri, 23 Jan 2009 07:19:34 +0000 (+0000) Subject: web service MDL-12886 temporary: REST protocol uses a special user by default (wsuser... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a6a544b24d7bb974842f6075174b12773954d748;p=moodle.git web service MDL-12886 temporary: REST protocol uses a special user by default (wsuser/wspassword) - give him some admin rights in order to test REST server --- diff --git a/webservice/rest/locallib.php b/webservice/rest/locallib.php index 9297c9b844..b93a186b67 100644 --- a/webservice/rest/locallib.php +++ b/webservice/rest/locallib.php @@ -32,18 +32,21 @@ function call_moodle_function ($rest_arguments) { if ($functionname != 'tmp_get_token') { throw new moodle_exception('identifyfirst'); } else { - if (optional_param('username',null,PARAM_ALPHANUM) == 'admin' && optional_param('password',null,PARAM_ALPHANUM) == 'admin') { + ///TODO: authentication + token generation need to be implemented + if (optional_param('username',null,PARAM_ALPHANUM) == 'wsuser' && optional_param('password',null,PARAM_ALPHANUM) == 'wspassword') { return '465465465468468464'; } else { throw new moodle_exception('wrongusernamepassword'); } } } else { + ///TDO: following function will need to be modified $user = mock_check_token($token); if (empty($user)) { throw new moodle_exception('wrongidentification'); } else { + ///TODO: probably change this $USER = $user; } } @@ -82,7 +85,7 @@ function mock_check_token($token) { if ($token == 465465465468468464) { ///retrieve the user global $DB; - $user = $DB->get_record('user', array('username'=>'admin', 'mnethostid'=>1)); + $user = $DB->get_record('user', array('username'=>'wsuser', 'mnethostid'=>1)); if (empty($user)) { return false; diff --git a/webservice/rest/testclient/createuser.php b/webservice/rest/testclient/createuser.php index 3b86fab617..3b2f8e0c65 100644 --- a/webservice/rest/testclient/createuser.php +++ b/webservice/rest/testclient/createuser.php @@ -22,8 +22,8 @@ $data['email'] = "mockuser5@lastname.com"; var_dump($data); //we are asking for a token -$connectiondata['username'] = 'admin'; -$connectiondata['password'] = 'admin'; +$connectiondata['username'] = 'wsuser'; +$connectiondata['password'] = 'wspassword'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/webservice/rest/testclient/deleteuser.php b/webservice/rest/testclient/deleteuser.php index a83e99bd46..e65f4ec7ed 100644 --- a/webservice/rest/testclient/deleteuser.php +++ b/webservice/rest/testclient/deleteuser.php @@ -32,8 +32,8 @@ start_interface("Delete a user"); if ($username) { //we are asking for a token - $connectiondata['username'] = 'admin'; - $connectiondata['password'] = 'admin'; + $connectiondata['username'] = 'wsuser'; + $connectiondata['password'] = 'wspassword'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/webservice/rest/testclient/getusers.php b/webservice/rest/testclient/getusers.php index 44e9eef1d2..0f1567ac06 100644 --- a/webservice/rest/testclient/getusers.php +++ b/webservice/rest/testclient/getusers.php @@ -36,8 +36,8 @@ if ($search) { //we are asking for a token - $connectiondata['username'] = 'admin'; - $connectiondata['password'] = 'admin'; + $connectiondata['username'] = 'wsuser'; + $connectiondata['password'] = 'wspassword'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/webservice/rest/testclient/updateuser.php b/webservice/rest/testclient/updateuser.php index 65b9fd94c3..978ca0b687 100644 --- a/webservice/rest/testclient/updateuser.php +++ b/webservice/rest/testclient/updateuser.php @@ -34,8 +34,8 @@ start_interface("Update a user"); if ($username) { //we are asking for a token - $connectiondata['username'] = 'admin'; - $connectiondata['password'] = 'admin'; + $connectiondata['username'] = 'wsuser'; + $connectiondata['password'] = 'wspassword'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);