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.
This commit is contained in:
parent
4eee369b66
commit
12e369b2b6
3 changed files with 6 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue