mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-15 20:48:01 +08:00
fix(tokens): Don't assume that keytar is sync, don't wipe until next save
This commit is contained in:
parent
0056773769
commit
0a8e578e9f
1 changed files with 8 additions and 7 deletions
|
@ -45,19 +45,19 @@ class AccountStore extends NylasStore
|
|||
for json in NylasEnv.config.get(configAccountsKey) || []
|
||||
@_accounts.push((new Account).fromJSON(json))
|
||||
|
||||
# Load tokens using the old config method and save them into the keychain
|
||||
oldTokens = NylasEnv.config.get(configTokensKey)
|
||||
if oldTokens
|
||||
# Load tokens using the old config method and save them into the keychain
|
||||
@_tokens = oldTokens
|
||||
for key, val of oldTokens
|
||||
account = @accountForId(key)
|
||||
continue unless account
|
||||
keytar.replacePassword(keytarServiceName, account.emailAddress, val)
|
||||
NylasEnv.config.set(configTokensKey, null)
|
||||
|
||||
# Load tokens using the new keytar method
|
||||
@_tokens = {}
|
||||
for account in @_accounts
|
||||
@_tokens[account.id] = keytar.getPassword(keytarServiceName, account.emailAddress)
|
||||
else
|
||||
# Load tokens using the new keytar method
|
||||
@_tokens = {}
|
||||
for account in @_accounts
|
||||
@_tokens[account.id] = keytar.getPassword(keytarServiceName, account.emailAddress)
|
||||
|
||||
@_trigger()
|
||||
|
||||
|
@ -73,6 +73,7 @@ class AccountStore extends NylasStore
|
|||
@_version += 1
|
||||
NylasEnv.config.set(configVersionKey, @_version)
|
||||
NylasEnv.config.set(configAccountsKey, @_accounts)
|
||||
NylasEnv.config.set(configTokensKey, null)
|
||||
NylasEnv.config.save()
|
||||
@_trigger()
|
||||
|
||||
|
|
Loading…
Reference in a new issue