From ad348cbdf92ae4cf7022c93dc16ed8be4bc969b4 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Mon, 14 Sep 2015 14:00:23 +0800 Subject: [PATCH] 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. --- lib/ajax/service.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ajax/service.php b/lib/ajax/service.php index 366f1ad16ff..ce58f01d026 100644 --- a/lib/ajax/service.php +++ b/lib/ajax/service.php @@ -58,6 +58,11 @@ foreach ($requests as $request) { // Do not allow access to write or delete webservices as a public user. 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()) { error_log('This external function is not available to public users. Failed to call "' . $methodname . '"'); throw new moodle_exception('servicenotavailable', 'webservice');