fix(plugin-auth): Once plguin auth succeeds, don't do it again

This commit is contained in:
Ben Gotow 2016-02-26 16:39:45 -08:00
parent 28b995e19c
commit 68d89504f7

View file

@ -396,6 +396,11 @@ class NylasAPI
AccountStore ?= require './stores/account-store'
AccountStore.accountForId(accountOrId)
Promise.reject(new Error('Invalid account')) unless account
cacheKey = "plugins.#{pluginId}.lastAuthTimestamp"
if NylasEnv.config.get(cacheKey)
return Promise.resolve()
return @makeRequest({
returnsModel: false,
method: "GET",
@ -404,9 +409,11 @@ class NylasAPI
})
.then (result) =>
if result.authed
NylasEnv.config.set(cacheKey, Date.now())
return Promise.resolve()
else
# return @_requestPluginAuth(pluginName, account).then =>
# Enable to show a prompt to the user
# return @_requestPluginAuth(pluginName, account).then =>
return @makeRequest({
returnsModel: false,
method: "POST",