mnet MDL-21466 change "WS auth not enable" for "Web Service Authentication plugin is disabled" message + add hard coded ws error message string into lang file.

This commit is contained in:
jerome mouneyrac 2010-01-29 02:15:22 +00:00
parent 5b7984a57a
commit b0a9a0cd35
3 changed files with 17 additions and 11 deletions

View File

@ -1,6 +1,7 @@
<?php
$string['accessexception'] = 'Access control exception';
$string['accessnotallowed'] = 'Access to web service not allowed';
$string['activatehttps'] = '******************';
$string['addcapabilitytousers'] = 'Check users capability';
$string['addcapabilitytousersdescription'] = 'To use web services, users need to have two different capabilities: \'/webservice:createtoken\' and a capability matching the web service protocols (\'webservice/rest:use\', \'webservice/soap:use\', ...).';
@ -63,6 +64,8 @@ $string['iprestriction'] = 'IP restriction';
$string['key'] = 'Key';
$string['manageprotocols'] = 'Manage protocols';
$string['managetokens'] = 'Manage tokens';
$string['missingpassword'] = 'Missing password';
$string['missingusername'] = 'Missing username';
$string['norequiredcapability'] = 'No required capability';
$string['notoken'] = 'The token list is empty.';
$string['onesystemcontrolling'] = 'One system controlling Moodle with token';
@ -111,6 +114,9 @@ $string['userasclientsdescription'] = 'The following steps help you to set up th
$string['webservices'] = 'Web services';
$string['webservicesoverview'] = 'Overview';
$string['webservicetokens'] = 'Web service tokens';
$string['wrongusernamepassword'] = 'Wrong username or password';
$string['wsauthmissing'] = 'The web service authentication plugin is missing.';
$string['wsauthnotenabled'] = 'The web service authentication plugin is disabled.';
$string['wsdocumentation'] = 'Web service documentation';
$string['wsdocumentationdisable'] = 'Web service documentation is disabled.';
$string['wsdocumentationintro'] = 'Following is a listing of web service functions available for the username <b>$a</b>.<br/>To create a client we advise you to read the <a href=\"http://docs.moodle.org/en/Development:Creating_a_web_service_and_a_web_service_function#Create_your_own_client\">Moodle documentation</a>';

View File

@ -130,11 +130,11 @@ abstract class webservice_server implements webservice_server_interface {
}
if (!is_enabled_auth('webservice')) {
throw new webservice_access_exception('WS auth not enabled');
throw new webservice_access_exception(get_string('wsauthnotenabled', 'webservice'));
}
if (!$auth = get_auth_plugin('webservice')) {
throw new webservice_access_exception('WS auth missing');
throw new webservice_access_exception(get_string('wsauthmissing', 'webservice'));
}
// NOTE: the exception details are here for debugging only, it is controlled via the $CFG->degug
@ -143,17 +143,17 @@ abstract class webservice_server implements webservice_server_interface {
$this->restricted_context = get_context_instance(CONTEXT_SYSTEM);
if (!$this->username) {
throw new webservice_access_exception('Missing username');
throw new webservice_access_exception(get_string('missingusername', 'webservice'));
}
if (!$this->password) {
throw new webservice_access_exception('Missing password');
throw new webservice_access_exception(get_string('missingpassword', 'webservice'));
}
if (!$auth->user_login_webservice($this->username, $this->password)) {
// log failed login attempts
add_to_log(1, 'webservice', get_string('simpleauthlog', 'webservice'), '' , get_string('failedtolog', 'webservice').": ".$this->username."/".$this->password." - ".getremoteaddr() , 0);
throw new webservice_access_exception('Wrong username or password');
throw new webservice_access_exception(get_string('wrongusernamepassword', 'webservice'));
}
$user = $DB->get_record('user', array('username'=>$this->username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0), '*', MUST_EXIST);
@ -188,7 +188,7 @@ abstract class webservice_server implements webservice_server_interface {
$this->userid = $user->id;
if (!has_capability("webservice/$this->wsname:use", $this->restricted_context)) {
throw new webservice_access_exception('Access to web service not allowed');
throw new webservice_access_exception(get_string('accessnotallowed', 'webservice'));
}
external_api::set_context_restriction($this->restricted_context);

View File

@ -189,23 +189,23 @@ class webservice_documentation_generator {
}
if (!is_enabled_auth('webservice')) {
throw new webservice_access_exception('WS auth not enabled');
throw new webservice_access_exception(get_string('wsauthnotenabled', 'webservice'));
}
if (!$auth = get_auth_plugin('webservice')) {
throw new webservice_access_exception('WS auth missing');
throw new webservice_access_exception(get_string('wsauthmissing', 'webservice'));
}
if (!$this->username) {
throw new webservice_access_exception('Missing username');
throw new webservice_access_exception(get_string('missingusername', 'webservice'));
}
if (!$this->password) {
throw new webservice_access_exception('Missing password');
throw new webservice_access_exception(get_string('missingpassword', 'webservice'));
}
if (!$auth->user_login_webservice($this->username, $this->password)) {
throw new webservice_access_exception('Wrong username or password');
throw new webservice_access_exception(get_string('wrongusernamepassword', 'webservice'));
}
$this->webserviceuser = $DB->get_record('user', array('username'=>$this->username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0), '*', MUST_EXIST);