Fixing session and logout errors

This commit is contained in:
Christopher Speller
2016-03-30 11:07:03 -04:00
parent 8283c18cb0
commit bf90d98136
4 changed files with 9 additions and 9 deletions

View File

@@ -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() {

View File

@@ -142,6 +142,8 @@ function preLoggedIn(nextState, replace, callback) {
const d2 = AsyncClient.getChannels();
ErrorStore.clearLastError();
$.when(d1, d2).done(() => {
callback();
});

View File

@@ -59,6 +59,7 @@ class ErrorStoreClass extends EventEmitter {
clearLastError() {
BrowserStore.removeGlobalItem('last_error');
BrowserStore.removeGlobalItem('last_error_conn');
this.emitChange();
}
}

View File

@@ -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;