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.
This commit is contained in:
Karim Hamidou 2017-01-15 12:09:22 -08:00
parent 1f0d46bcd7
commit 1d740240aa

View file

@ -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)