commit 12e369b2b683b1d7885fd3f84f3c685fc579dc5b
parent 4eee369b6642daeaa52f7a4c913e5129d67c89a0
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 25 Apr 2016 03:12:11 -0400
Show the invalid login prompt for an invalid API key
Addresses #953, but the message should still be updated to be more
precise now that passwords aren't used directly.
Diffstat:
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/chrome/content/zotero/xpcom/error.js b/chrome/content/zotero/xpcom/error.js
@@ -41,7 +41,7 @@ Zotero.Error.ERROR_UNKNOWN = 0;
Zotero.Error.ERROR_MISSING_OBJECT = 1;
Zotero.Error.ERROR_FULL_SYNC_REQUIRED = 2;
Zotero.Error.ERROR_API_KEY_NOT_SET = 3;
-Zotero.Error.ERROR_INVALID_SYNC_LOGIN = 4;
+Zotero.Error.ERROR_API_KEY_INVALID = 4;
Zotero.Error.ERROR_ZFS_OVER_QUOTA = 5;
Zotero.Error.ERROR_ZFS_UPLOAD_QUEUE_LIMIT = 6;
Zotero.Error.ERROR_ZFS_FILE_EDITING_DENIED = 7;
diff --git a/chrome/content/zotero/xpcom/sync/syncAPIClient.js b/chrome/content/zotero/xpcom/sync/syncAPIClient.js
@@ -50,9 +50,9 @@ Zotero.Sync.APIClient.prototype = {
var uri = this.baseURL + "keys/current";
let opts = {};
Object.assign(opts, options);
- opts.successCodes = [200, 404];
+ opts.successCodes = [200, 403, 404];
var xmlhttp = yield this.makeRequest("GET", uri, opts);
- if (xmlhttp.status == 404) {
+ if (xmlhttp.status == 403 || xmlhttp.status == 404) {
return false;
}
var json = this._parseJSON(xmlhttp.responseText);
diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js
@@ -121,7 +121,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
try {
let apiKey = yield _getAPIKey();
if (!apiKey) {
- 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_NOT_SET);
}
if (_firstInSession) {
@@ -241,8 +241,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
var json = yield client.getKeyInfo(options);
Zotero.debug(json);
if (!json) {
- // TODO: Nicer error message
- throw new Error("Invalid API key");
+ throw new Zotero.Error("API key not set", Zotero.Error.ERROR_API_KEY_NOT_SET);
}
// Sanity check
@@ -843,7 +842,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
if (e.name && e.name == 'Zotero Error') {
switch (e.error) {
case Zotero.Error.ERROR_API_KEY_NOT_SET:
- case Zotero.Error.ERROR_INVALID_SYNC_LOGIN:
+ case Zotero.Error.ERROR_API_KEY_INVALID:
// TODO: the setTimeout() call below should just simulate a click on the sync error icon
// instead of creating its own dialog, but updateIcons() doesn't yet provide full control
// over dialog title and primary button text/action, which is why this version of the