Skip to content

Commit 627b0a7

Browse files
author
David Monllao
committed
Merge branch 'MDL-63210_35' of git://github.com/markn86/moodle into MOODLE_35_STABLE
2 parents f873ff9 + b5c2fef commit 627b0a7

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

lang/en/webservice.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
$string['servicehelpexplanation'] = 'A service is a set of functions. A service can be accessed by all users or just specified users.';
187187
$string['servicename'] = 'Service name';
188188
$string['servicenotavailable'] = 'Web service is not available (it doesn\'t exist or might be disabled)';
189+
$string['servicerequireslogin'] = 'Web service is not available (the session has been logged out or has expired)';
189190
$string['servicesbuiltin'] = 'Built-in services';
190191
$string['servicescustom'] = 'Custom services';
191192
$string['serviceusers'] = 'Authorised users';

lib/amd/build/ajax.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/amd/src/ajax.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2626
* @since 2.9
2727
*/
28-
define(['jquery', 'core/config', 'core/log'], function($, config, Log) {
28+
define(['jquery', 'core/config', 'core/log', 'core/url'], function($, config, Log, URL) {
2929

3030
// Keeps track of when the user leaves the page so we know not to show an error.
3131
var unloading = false;
@@ -79,9 +79,13 @@ define(['jquery', 'core/config', 'core/log'], function($, config, Log) {
7979
}
8080
// Something failed, reject the remaining promises.
8181
if (exception !== null) {
82-
for (; i < requests.length; i++) {
83-
request = requests[i];
84-
request.deferred.reject(exception);
82+
// Redirect to the login page.
83+
if (exception.errorcode === "servicerequireslogin") {
84+
window.location = URL.relativeUrl("/login/index.php");
85+
} else {
86+
requests.forEach(function(request) {
87+
request.deferred.reject(exception);
88+
});
8589
}
8690
}
8791
};

lib/externallib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ public static function call_external_function($function, $args, $ajaxonly=false)
208208
// Do not allow access to write or delete webservices as a public user.
209209
if ($externalfunctioninfo->loginrequired) {
210210
if (defined('NO_MOODLE_COOKIES') && NO_MOODLE_COOKIES && !PHPUNIT_TEST) {
211-
throw new moodle_exception('servicenotavailable', 'webservice');
211+
throw new moodle_exception('servicerequireslogin', 'webservice');
212212
}
213213
if (!isloggedin()) {
214-
throw new moodle_exception('servicenotavailable', 'webservice');
214+
throw new moodle_exception('servicerequireslogin', 'webservice');
215215
} else {
216216
require_sesskey();
217217
}

0 commit comments

Comments
 (0)