Merge pull request #979 from adomasven/fix/old-sync-credentials-to-apikey

Fixes sync error when transfering credentials from legacy to API key
This commit is contained in:
Dan Stillman 2016-04-28 10:23:59 -04:00
commit 3663f13fa9

View file

@ -1278,12 +1278,11 @@ Zotero.Sync.Runner_Module = function (options = {}) {
// Set in login manager // Set in login manager
|| Zotero.Sync.Data.Local.getAPIKey() || Zotero.Sync.Data.Local.getAPIKey()
// Fallback to old username/password // Fallback to old username/password
|| (yield _getAPIKeyFromLogin()); || _getAPIKeyFromLogin();
}) })
var _getAPIKeyFromLogin = Zotero.Promise.coroutine(function* () { var _getAPIKeyFromLogin = Zotero.Promise.coroutine(function* () {
var apiKey;
let username = Zotero.Prefs.get('sync.server.username'); let username = Zotero.Prefs.get('sync.server.username');
if (username) { if (username) {
// Check for legacy password if no password set in current session // Check for legacy password if no password set in current session
@ -1293,9 +1292,9 @@ Zotero.Sync.Runner_Module = function (options = {}) {
return ""; return "";
} }
apiKey = yield Zotero.Sync.Runner.createAPIKeyFromCredentials(username, password); let json = yield Zotero.Sync.Runner.createAPIKeyFromCredentials(username, password);
Zotero.Sync.Data.Local.removeLegacyLogins(); Zotero.Sync.Data.Local.removeLegacyLogins();
return apiKey; return json.key;
} }
return ""; return "";
}) })