fix(plugin-auth): more fixes to plugin auth

This commit is contained in:
Drew Regitsky 2016-02-10 17:47:10 -08:00
parent e91c9b82f5
commit ab527ab3a5

View file

@ -383,7 +383,9 @@ class NylasAPI
# 3. The API request to auth this account to the plugin failed. This may mean that
# the plugin server couldn't be reached or failed to respond properly when authing
# the account, or that the Nylas API couldn't be reached.
authPlugin: (pluginId, pluginName, account) ->
authPlugin: (pluginId, pluginName, accountId) ->
AccountStore = AccountStore || require './stores/account-store'
account = AccountStore.accountForId(accountId)
return @makeRequest({
returnsModel: false,
method: "GET",
@ -393,12 +395,12 @@ class NylasAPI
if result.authed
return Promise.resolve()
else
return @_requestPluginAuth(pluginName, account).then( -> @makeRequest({
return @_requestPluginAuth(pluginName, account).then( => @makeRequest({
returnsModel: false,
method: "POST",
accountId: account.id,
path: "/auth/plugin",
body: JSON.stringify({client_id: pluginId}),
body: {client_id: pluginId},
json: true
}))
)
@ -422,11 +424,11 @@ You can review and revoke Offline Access for plugins at any time from Preference
)
)
unauthPlugin: (pluginId, account) ->
unauthPlugin: (pluginId, accountId) ->
return @makeRequest({
returnsModel: false,
method: "DELETE",
accountId: account.id,
accountId: accountId,
path: "/auth/plugin?client_id=#{pluginId}"
});