From 24342e7617b30a6ec899a34a7e37be9fddc11632 Mon Sep 17 00:00:00 2001 From: Thom Rawson Date: Sun, 6 May 2018 14:25:39 +0900 Subject: [PATCH 1/3] MDL-63210 core: AJAX call redirects to login page when session expired Backport of MDL-54551. --- lang/en/webservice.php | 1 + lib/amd/build/ajax.min.js | 2 +- lib/amd/src/ajax.js | 19 +++++++++++++++---- lib/externallib.php | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lang/en/webservice.php b/lang/en/webservice.php index b6cf1de44d0..20af1fe4612 100644 --- a/lang/en/webservice.php +++ b/lang/en/webservice.php @@ -186,6 +186,7 @@ $string['service'] = 'Service'; $string['servicehelpexplanation'] = 'A service is a set of functions. A service can be accessed by all users or just specified users.'; $string['servicename'] = 'Service name'; $string['servicenotavailable'] = 'Web service is not available (it doesn\'t exist or might be disabled)'; +$string['servicerequireslogin'] = 'Web service requires login (the session has been logged out or has expired. Please save any work on the current page before continuing)'; $string['servicesbuiltin'] = 'Built-in services'; $string['servicescustom'] = 'Custom services'; $string['serviceusers'] = 'Authorised users'; diff --git a/lib/amd/build/ajax.min.js b/lib/amd/build/ajax.min.js index 8247f327b0c..8a6dfe49193 100644 --- a/lib/amd/build/ajax.min.js +++ b/lib/amd/build/ajax.min.js @@ -1 +1 @@ -define(["jquery","core/config","core/log"],function(a,b,c){var d=!1,e=function(a){var b,c,d=this,e=null,f=0;if(a.error)for(;floginrequired) { if (defined('NO_MOODLE_COOKIES') && NO_MOODLE_COOKIES && !PHPUNIT_TEST) { - throw new moodle_exception('servicenotavailable', 'webservice'); + throw new moodle_exception('servicerequireslogin', 'webservice'); } if (!isloggedin()) { - throw new moodle_exception('servicenotavailable', 'webservice'); + throw new moodle_exception('servicerequireslogin', 'webservice'); } else { require_sesskey(); } From a456850616af7fe6a8c37f21fac47bebcf6cfa7e Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 18 Jul 2018 17:52:34 +0800 Subject: [PATCH 2/3] MDL-63210 core: touch-up after review 1. Reworded the string. 2. Removed logic handling form data. 3. Do not use window.location.replace. Backport of MDL-54551. --- lang/en/webservice.php | 2 +- lib/amd/build/ajax.min.js | 2 +- lib/amd/src/ajax.js | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lang/en/webservice.php b/lang/en/webservice.php index 20af1fe4612..1aac8701e72 100644 --- a/lang/en/webservice.php +++ b/lang/en/webservice.php @@ -186,7 +186,7 @@ $string['service'] = 'Service'; $string['servicehelpexplanation'] = 'A service is a set of functions. A service can be accessed by all users or just specified users.'; $string['servicename'] = 'Service name'; $string['servicenotavailable'] = 'Web service is not available (it doesn\'t exist or might be disabled)'; -$string['servicerequireslogin'] = 'Web service requires login (the session has been logged out or has expired. Please save any work on the current page before continuing)'; +$string['servicerequireslogin'] = 'Web service is not available (the session has been logged out or has expired)'; $string['servicesbuiltin'] = 'Built-in services'; $string['servicescustom'] = 'Custom services'; $string['serviceusers'] = 'Authorised users'; diff --git a/lib/amd/build/ajax.min.js b/lib/amd/build/ajax.min.js index 8a6dfe49193..a585b990bfb 100644 --- a/lib/amd/build/ajax.min.js +++ b/lib/amd/build/ajax.min.js @@ -1 +1 @@ -define(["jquery","core/config","core/log","core/yui","core/url"],function(a,b,c,d,e){var f=!1,g=function(a){var b,c,f=this,g=null,h=0;if(a.error)for(;h Date: Fri, 24 Aug 2018 11:31:32 +0800 Subject: [PATCH 3/3] MDL-63210 core: convert for loop to forEach in JS --- lib/amd/build/ajax.min.js | 2 +- lib/amd/src/ajax.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/amd/build/ajax.min.js b/lib/amd/build/ajax.min.js index a585b990bfb..f8c54537985 100644 --- a/lib/amd/build/ajax.min.js +++ b/lib/amd/build/ajax.min.js @@ -1 +1 @@ -define(["jquery","core/config","core/log","core/url"],function(a,b,c,d){var e=!1,f=function(a){var b,c,e=this,f=null,g=0;if(a.error)for(;g