From 9ac730cccc1aa08f7e01c5672062071dcd9f4afa Mon Sep 17 00:00:00 2001 From: Jackie Luo Date: Fri, 2 Sep 2016 17:10:51 -0700 Subject: [PATCH] fix(identity): Log user out of app if identity token is missing --- src/flux/nylas-api-request.es6 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/flux/nylas-api-request.es6 b/src/flux/nylas-api-request.es6 index 8dec633ea..da25da122 100644 --- a/src/flux/nylas-api-request.es6 +++ b/src/flux/nylas-api-request.es6 @@ -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);