diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-03-30 11:07:03 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-03-30 15:29:21 -0400 |
commit | bf90d98136965dfd37546e5ecb23d8c6970bed8a (patch) | |
tree | b2c3944a2a33d20cc566318ab44aa12eecd51d8d | |
parent | 8283c18cb0ab3ef7a07f6a6f2d5ae61c109dae96 (diff) | |
download | chat-bf90d98136965dfd37546e5ecb23d8c6970bed8a.tar.gz chat-bf90d98136965dfd37546e5ecb23d8c6970bed8a.tar.bz2 chat-bf90d98136965dfd37546e5ecb23d8c6970bed8a.zip |
Fixing session and logout errors
-rw-r--r-- | webapp/components/login/login.jsx | 7 | ||||
-rw-r--r-- | webapp/root.jsx | 2 | ||||
-rw-r--r-- | webapp/stores/error_store.jsx | 1 | ||||
-rw-r--r-- | webapp/utils/client.jsx | 8 |
4 files changed, 9 insertions, 9 deletions
diff --git a/webapp/components/login/login.jsx b/webapp/components/login/login.jsx index 7b370a939..e867af47a 100644 --- a/webapp/components/login/login.jsx +++ b/webapp/components/login/login.jsx @@ -27,7 +27,9 @@ export default class Login extends React.Component { this.preSubmit = this.preSubmit.bind(this); this.submit = this.submit.bind(this); - this.state = this.getStateFromStores(); + const state = this.getStateFromStores(); + state.doneCheckLogin = false; + this.state = state; } componentDidMount() { TeamStore.addChangeListener(this.onTeamChange); @@ -44,8 +46,7 @@ export default class Login extends React.Component { } getStateFromStores() { return { - currentTeam: TeamStore.getByName(this.props.params.team), - doneCheckLogin: false + currentTeam: TeamStore.getByName(this.props.params.team) }; } onTeamChange() { diff --git a/webapp/root.jsx b/webapp/root.jsx index adabe3fa3..9c2708506 100644 --- a/webapp/root.jsx +++ b/webapp/root.jsx @@ -142,6 +142,8 @@ function preLoggedIn(nextState, replace, callback) { const d2 = AsyncClient.getChannels(); + ErrorStore.clearLastError(); + $.when(d1, d2).done(() => { callback(); }); diff --git a/webapp/stores/error_store.jsx b/webapp/stores/error_store.jsx index 7c695a335..715029185 100644 --- a/webapp/stores/error_store.jsx +++ b/webapp/stores/error_store.jsx @@ -59,6 +59,7 @@ class ErrorStoreClass extends EventEmitter { clearLastError() { BrowserStore.removeGlobalItem('last_error'); BrowserStore.removeGlobalItem('last_error_conn'); + this.emitChange(); } } diff --git a/webapp/utils/client.jsx b/webapp/utils/client.jsx index a596d1e14..854aa31dc 100644 --- a/webapp/utils/client.jsx +++ b/webapp/utils/client.jsx @@ -50,12 +50,8 @@ function handleError(methodName, xhr, status, err) { track('api', 'api_weberror', methodName, 'message', msg); if (xhr.status === 401) { - if (window.location.href.indexOf('/channels') === 0) { - browserHistory.push('/login?extra=expired&redirect=' + encodeURIComponent(window.location.pathname + window.location.search)); - } else { - var teamURL = window.location.pathname.split('/channels')[0]; - browserHistory.push(teamURL + '/login?extra=expired&redirect=' + encodeURIComponent(window.location.pathname + window.location.search)); - } + const team = window.location.pathname.split('/')[1]; + browserHistory.push('/' + team + '/login?extra=expired&redirect=' + encodeURIComponent(window.location.pathname + window.location.search)); } return e; |