MOBILE-2788 ws: Save permission errors to the cache
parent
381db52efe
commit
1fcc4dbfd5
|
@ -1517,6 +1517,7 @@
|
||||||
"core.nograde": "moodle",
|
"core.nograde": "moodle",
|
||||||
"core.none": "moodle",
|
"core.none": "moodle",
|
||||||
"core.nopasswordchangeforced": "local_moodlemobileapp",
|
"core.nopasswordchangeforced": "local_moodlemobileapp",
|
||||||
|
"core.nopermissionerror": "local_moodlemobileapp",
|
||||||
"core.nopermissions": "error",
|
"core.nopermissions": "error",
|
||||||
"core.noresults": "moodle",
|
"core.noresults": "moodle",
|
||||||
"core.notapplicable": "local_moodlemobileapp",
|
"core.notapplicable": "local_moodlemobileapp",
|
||||||
|
|
|
@ -1518,6 +1518,7 @@
|
||||||
"core.nograde": "No grade",
|
"core.nograde": "No grade",
|
||||||
"core.none": "None",
|
"core.none": "None",
|
||||||
"core.nopasswordchangeforced": "You cannot proceed without changing your password.",
|
"core.nopasswordchangeforced": "You cannot proceed without changing your password.",
|
||||||
|
"core.nopermissionerror": "Sorry, but you do not currently have permissions to do that",
|
||||||
"core.nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
"core.nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
||||||
"core.noresults": "No results",
|
"core.noresults": "No results",
|
||||||
"core.notapplicable": "n/a",
|
"core.notapplicable": "n/a",
|
||||||
|
|
|
@ -671,6 +671,16 @@ export class CoreSite {
|
||||||
// This should not happen.
|
// This should not happen.
|
||||||
error.message = this.translate.instant('core.unicodenotsupported');
|
error.message = this.translate.instant('core.unicodenotsupported');
|
||||||
|
|
||||||
|
return Promise.reject(error);
|
||||||
|
} else if (error.exception === 'required_capability_exception' || error.errorcode === 'nopermission') {
|
||||||
|
if (error.message === 'error/nopermission') {
|
||||||
|
// This error message is returned by some web services but the string does not exist.
|
||||||
|
error.message = this.translate.instant('core.nopermissionerror');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the error instead of deleting the cache entry so the same content is displayed in offline.
|
||||||
|
this.saveToCache(method, data, error, preSets);
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
} else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) {
|
} else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) {
|
||||||
this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`);
|
this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`);
|
||||||
|
@ -695,6 +705,13 @@ export class CoreSite {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}).then((response) => {
|
||||||
|
// Check if the response is an error, this happens if the error was stored in the cache.
|
||||||
|
if (response && typeof response.exception !== 'undefined') {
|
||||||
|
return Promise.reject(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@
|
||||||
"nograde": "No grade",
|
"nograde": "No grade",
|
||||||
"none": "None",
|
"none": "None",
|
||||||
"nopasswordchangeforced": "You cannot proceed without changing your password.",
|
"nopasswordchangeforced": "You cannot proceed without changing your password.",
|
||||||
|
"nopermissionerror": "Sorry, but you do not currently have permissions to do that",
|
||||||
"nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
"nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
||||||
"noresults": "No results",
|
"noresults": "No results",
|
||||||
"notapplicable": "n/a",
|
"notapplicable": "n/a",
|
||||||
|
|
Loading…
Reference in New Issue