From 6139f7045ecfc64bd43232377c864ccf3c9fac77 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 21 Sep 2016 00:46:28 -0400 Subject: [PATCH] Fix automatic syncing when no legacy password --- chrome/content/zotero/xpcom/sync/syncLocal.js | 14 ++++++++++++++ chrome/content/zotero/xpcom/sync/syncRunner.js | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) 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 });