Don't unlink account on key info request connection failure

This can happen when the computer is offline but that hasn't been
detected for some reason.
This commit is contained in:
Dan Stillman 2017-08-05 01:07:49 +02:00
parent 198fb28e20
commit 7b0ed6da81
3 changed files with 3 additions and 5 deletions

View file

@ -51,9 +51,7 @@ Zotero_Preferences.Sync = {
}
catch (e) {
// API key wrong/invalid
if (!(e instanceof Zotero.HTTP.UnexpectedStatusException)
&& !(e instanceof Zotero.HTTP.TimeoutException)
&& !(e instanceof Zotero.HTTP.BrowserOfflineException)) {
if (e instanceof Zotero.Error && e.error == Zotero.Error.ERROR_API_KEY_INVALID) {
Zotero.alert(
window,
Zotero.getString('general.error'),

View file

@ -55,7 +55,7 @@ Zotero.Sync.APIClient.prototype = {
Object.assign(opts, options);
opts.successCodes = [200, 403, 404];
var xmlhttp = yield this.makeRequest("GET", uri, opts);
if (xmlhttp.status == 403 || xmlhttp.status == 404) {
if (xmlhttp.status == 403) {
return false;
}
var json = this._parseJSON(xmlhttp.responseText);

View file

@ -269,7 +269,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
var json = yield client.getKeyInfo(options);
Zotero.debug(json);
if (!json) {
throw new Zotero.Error("API key not set", Zotero.Error.ERROR_API_KEY_NOT_SET);
throw new Zotero.Error("API key not set", Zotero.Error.ERROR_API_KEY_INVALID);
}
// Sanity check