MDL-50783 ajax: Add specific check for NO_MOODLE_COOKIES

If loginrequired is set for a webservice - NO_MOODLE_COOKIES cannot
be true - or it is a coding error.
This commit is contained in:
Damyon Wiese 2015-09-14 14:00:23 +08:00
parent ba224fb42c
commit ad348cbdf9

View file

@ -58,6 +58,11 @@ foreach ($requests as $request) {
// Do not allow access to write or delete webservices as a public user. // Do not allow access to write or delete webservices as a public user.
if ($externalfunctioninfo->loginrequired) { if ($externalfunctioninfo->loginrequired) {
if (defined('NO_MOODLE_COOKIES') && NO_MOODLE_COOKIES) {
error_log('Set "loginrequired" to false in db/service.php when calling entry point service-nologin.php. ' .
'Failed to call "' . $methodname . '"');
throw new moodle_exception('servicenotavailable', 'webservice');
}
if (!isloggedin()) { if (!isloggedin()) {
error_log('This external function is not available to public users. Failed to call "' . $methodname . '"'); error_log('This external function is not available to public users. Failed to call "' . $methodname . '"');
throw new moodle_exception('servicenotavailable', 'webservice'); throw new moodle_exception('servicenotavailable', 'webservice');