From 1d740240aa669fb7fa178c03d21525484f106684 Mon Sep 17 00:00:00 2001 From: Karim Hamidou Date: Sun, 15 Jan 2017 12:09:22 -0800 Subject: [PATCH] HACK HACK HACK Allow querying account tokens by email address too. We've got a plethora of "unique" ids for the same account and ot looks like a recent regression is preventing us from fetching an API token for an account from the keychain. This diff changes the AccountStore to be able to fetch data using an account's email address. Will figure how to do things better after launch. Test plan: Checked that it worked for a broken account. --- src/flux/stores/account-store.es6 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/flux/stores/account-store.es6 b/src/flux/stores/account-store.es6 index f8b2941b3..0062faa84 100644 --- a/src/flux/stores/account-store.es6 +++ b/src/flux/stores/account-store.es6 @@ -78,10 +78,15 @@ class AccountStore extends NylasStore { // Load tokens using the new KeyManager method this._tokens = {} for (const account of this._accounts) { - this._tokens[account.id] = { + const credentials = { n1Cloud: KeyManager.getPassword(`${account.emailAddress}.n1Cloud`, {migrateFromService: "Nylas"}), localSync: KeyManager.getPassword(`${account.emailAddress}.localSync`, {migrateFromService: "Nylas"}), } + this._tokens[account.id] = credentials; + + // HACK HACK HACK. For some reason we're getting passed the wrong + // id. Figure this out after launch. + this._tokens[account.emailAddress] = credentials; } } catch (error) { NylasEnv.reportError(error)