diff --git a/chrome/content/zotero/xpcom/sync/syncLocal.js b/chrome/content/zotero/xpcom/sync/syncLocal.js index e934d23fed..ab797f97b5 100644 --- a/chrome/content/zotero/xpcom/sync/syncLocal.js +++ b/chrome/content/zotero/xpcom/sync/syncLocal.js @@ -54,6 +54,20 @@ Zotero.Sync.Data.Local = { }), + /** + * Check for an API key or a legacy username/password (which may or may not be valid) + */ + hasCredentials: function () { + var login = this._getAPIKeyLoginInfo(); + if (login) { + return true; + } + // If no API key, check for legacy login + var username = Zotero.Prefs.get('sync.server.username'); + return username && !!this.getLegacyPassword(username) + }, + + setAPIKey: function (apiKey) { var loginManager = Components.classes["@mozilla.org/login-manager;1"] .getService(Components.interfaces.nsILoginManager); diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js index 44f4c21613..650d7949c4 100644 --- a/chrome/content/zotero/xpcom/sync/syncRunner.js +++ b/chrome/content/zotero/xpcom/sync/syncRunner.js @@ -35,9 +35,7 @@ Zotero.Sync.Runner_Module = function (options = {}) { Zotero.defineProperty(this, 'enabled', { get: () => { - if (_apiKey) return true; - var username = Zotero.Prefs.get('sync.server.username'); - return username && Zotero.Sync.Data.Local.getLegacyPassword(username); + return _apiKey || Zotero.Sync.Data.Local.hasCredentials(); } }); Zotero.defineProperty(this, 'syncInProgress', { get: () => _syncInProgress });