mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-14 08:35:29 +08:00
fix(account): re-add token if a new one comes in
Summary: fix(account): allow users to reconnect accounts if auth has failed Test Plan: manual Reviewers: bengotow, juan Differential Revision: https://phab.nylas.com/D2663
This commit is contained in:
parent
a421ee2a80
commit
11c119393e
5 changed files with 23 additions and 14 deletions
|
@ -18,6 +18,12 @@ class AccountChoosePage extends React.Component
|
||||||
componentWillUnmount: ->
|
componentWillUnmount: ->
|
||||||
@_usub?()
|
@_usub?()
|
||||||
|
|
||||||
|
componentDidMount: ->
|
||||||
|
if @props.pageData.provider
|
||||||
|
providerData = _.findWhere(Providers, name: @props.pageData.provider)
|
||||||
|
if providerData
|
||||||
|
@_onChooseProvider(providerData)
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
<div className="page account-choose">
|
<div className="page account-choose">
|
||||||
<div className="quit" onClick={ -> OnboardingActions.closeWindow() }>
|
<div className="quit" onClick={ -> OnboardingActions.closeWindow() }>
|
||||||
|
|
|
@ -51,14 +51,14 @@ describe "NylasAPI", ->
|
||||||
spyOn(Actions, 'postNotification')
|
spyOn(Actions, 'postNotification')
|
||||||
NylasAPI._handleAuthenticationFailure('/threads/1234', 'token')
|
NylasAPI._handleAuthenticationFailure('/threads/1234', 'token')
|
||||||
expect(Actions.postNotification).toHaveBeenCalled()
|
expect(Actions.postNotification).toHaveBeenCalled()
|
||||||
expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas can no longer authenticate with your mail provider. You will not be able to send or receive mail. Please remove the account and sign in again.")
|
expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas N1 can no longer authenticate with your mail provider. You will not be able to send or receive mail. Please click here to reconnect your account.")
|
||||||
|
|
||||||
it "should include the email address if possible", ->
|
it "should include the email address if possible", ->
|
||||||
spyOn(AccountStore, 'tokenForAccountId').andReturn('token')
|
spyOn(AccountStore, 'tokenForAccountId').andReturn('token')
|
||||||
spyOn(Actions, 'postNotification')
|
spyOn(Actions, 'postNotification')
|
||||||
NylasAPI._handleAuthenticationFailure('/threads/1234', 'token')
|
NylasAPI._handleAuthenticationFailure('/threads/1234', 'token')
|
||||||
expect(Actions.postNotification).toHaveBeenCalled()
|
expect(Actions.postNotification).toHaveBeenCalled()
|
||||||
expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas can no longer authenticate with #{AccountStore.accounts()[0].emailAddress}. You will not be able to send or receive mail. Please remove the account and sign in again.")
|
expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas N1 can no longer authenticate with #{AccountStore.accounts()[0].emailAddress}. You will not be able to send or receive mail. Please click here to reconnect your account.")
|
||||||
|
|
||||||
describe "handleModelResponse", ->
|
describe "handleModelResponse", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
|
@ -271,7 +271,8 @@ class Application
|
||||||
nylasWindow ?= @windowManager.focusedWindow()
|
nylasWindow ?= @windowManager.focusedWindow()
|
||||||
nylasWindow?.browserWindow.inspectElement(x, y)
|
nylasWindow?.browserWindow.inspectElement(x, y)
|
||||||
|
|
||||||
@on 'application:add-account', => @windowManager.ensureOnboardingWindow()
|
@on 'application:add-account', (provider) =>
|
||||||
|
@windowManager.ensureOnboardingWindow({provider})
|
||||||
@on 'application:new-message', => @windowManager.sendToMainWindow('new-message')
|
@on 'application:new-message', => @windowManager.sendToMainWindow('new-message')
|
||||||
@on 'application:view-help', =>
|
@on 'application:view-help', =>
|
||||||
url = 'https://nylas.zendesk.com/hc/en-us/sections/203638587-N1'
|
url = 'https://nylas.zendesk.com/hc/en-us/sections/203638587-N1'
|
||||||
|
@ -389,8 +390,8 @@ class Application
|
||||||
win = BrowserWindow.fromWebContents(event.sender)
|
win = BrowserWindow.fromWebContents(event.sender)
|
||||||
@applicationMenu.update(win, template, keystrokesByCommand)
|
@applicationMenu.update(win, template, keystrokesByCommand)
|
||||||
|
|
||||||
ipcMain.on 'command', (event, command) =>
|
ipcMain.on 'command', (event, command, args...) =>
|
||||||
@emit(command)
|
@emit(command, args...)
|
||||||
|
|
||||||
ipcMain.on 'window-command', (event, command, args...) ->
|
ipcMain.on 'window-command', (event, command, args...) ->
|
||||||
win = BrowserWindow.fromWebContents(event.sender)
|
win = BrowserWindow.fromWebContents(event.sender)
|
||||||
|
|
|
@ -133,7 +133,7 @@ class WindowManager
|
||||||
|
|
||||||
# Returns a new onboarding window
|
# Returns a new onboarding window
|
||||||
#
|
#
|
||||||
ensureOnboardingWindow: ({welcome}={}) ->
|
ensureOnboardingWindow: ({welcome, provider}={}) ->
|
||||||
existing = @onboardingWindow()
|
existing = @onboardingWindow()
|
||||||
if existing
|
if existing
|
||||||
existing.focus()
|
existing.focus()
|
||||||
|
@ -147,6 +147,7 @@ class WindowManager
|
||||||
windowProps:
|
windowProps:
|
||||||
page: 'account-choose'
|
page: 'account-choose'
|
||||||
uniqueId: 'onboarding'
|
uniqueId: 'onboarding'
|
||||||
|
pageData: {provider}
|
||||||
|
|
||||||
if welcome
|
if welcome
|
||||||
options.title = "Welcome to N1"
|
options.title = "Welcome to N1"
|
||||||
|
|
|
@ -129,9 +129,9 @@ class NylasAPI
|
||||||
|
|
||||||
if NylasEnv.isMainWindow()
|
if NylasEnv.isMainWindow()
|
||||||
Actions.notificationActionTaken.listen ({notification, action}) ->
|
Actions.notificationActionTaken.listen ({notification, action}) ->
|
||||||
if action.id is '401:unlink'
|
if action.id is '401:reconnect'
|
||||||
Actions.switchPreferencesTab('Accounts')
|
ipc = require('electron').ipcRenderer
|
||||||
Actions.openPreferences()
|
ipc.send('command', 'application:add-account', action.provider)
|
||||||
|
|
||||||
_onConfigChanged: =>
|
_onConfigChanged: =>
|
||||||
prev = {@AppID, @APIRoot, @APITokens}
|
prev = {@AppID, @APIRoot, @APITokens}
|
||||||
|
@ -245,15 +245,16 @@ class NylasAPI
|
||||||
type: 'error'
|
type: 'error'
|
||||||
tag: '401'
|
tag: '401'
|
||||||
sticky: true
|
sticky: true
|
||||||
message: "Nylas can no longer authenticate with #{email}. You
|
message: "Nylas N1 can no longer authenticate with #{email}. You
|
||||||
will not be able to send or receive mail. Please remove the
|
will not be able to send or receive mail. Please click
|
||||||
account and sign in again.",
|
here to reconnect your account.",
|
||||||
icon: 'fa-sign-out'
|
icon: 'fa-sign-out'
|
||||||
actions: [{
|
actions: [{
|
||||||
default: true
|
default: true
|
||||||
dismisses: true
|
dismisses: true
|
||||||
label: 'Unlink'
|
label: 'Reconnect'
|
||||||
id: '401:unlink'
|
provider: account?.provider ? ""
|
||||||
|
id: '401:reconnect'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
|
|
Loading…
Add table
Reference in a new issue