fix(identity): Log user out of app if identity token is missing

This commit is contained in:
Jackie Luo 2016-09-02 17:10:51 -07:00
parent d47c5bf3dd
commit 9ac730cccc

View file

@ -1,4 +1,5 @@
import request from 'request'
import {remote} from 'electron'
import Utils from './models/utils'
import Actions from './actions'
import {APIError} from './errors'
@ -35,7 +36,15 @@ export default class NylasAPIRequest {
const identity = IdentityStore.identity();
if (identity && !identity.token) {
throw new Error("Identity is present but identity token is missing.");
const clickedIndex = remote.dialog.showMessageBox({
type: 'error',
message: 'Identity is present but identity token is missing.',
detail: `Actions like sending and receiving mail require this token. Please log back into your Nylas ID to restore it—your email accounts will not be removed in this process.`,
buttons: ['Log out'],
})
if (clickedIndex === 0) {
Actions.logoutNylasIdentity()
}
}
const accountToken = this.api.accessTokenForAccountId(this.options.accountId);