Fixed websocket to properly logout when logged out from another tab (#4546)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
db0314053e
Коммит
814d2fc88d
@@ -461,21 +461,23 @@ export function emitRemoteUserTypingEvent(channelId, userId, postParentId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emitUserLoggedOutEvent(redirectTo) {
|
export function emitUserLoggedOutEvent(redirectTo = '/', shouldSignalLogout = true) {
|
||||||
const rURL = (redirectTo && typeof redirectTo === 'string') ? redirectTo : '/';
|
|
||||||
Client.logout(
|
Client.logout(
|
||||||
() => {
|
() => {
|
||||||
BrowserStore.signalLogout();
|
if (shouldSignalLogout) {
|
||||||
|
BrowserStore.signalLogout();
|
||||||
|
}
|
||||||
|
|
||||||
BrowserStore.clear();
|
BrowserStore.clear();
|
||||||
ErrorStore.clearLastError();
|
ErrorStore.clearLastError();
|
||||||
PreferenceStore.clear();
|
PreferenceStore.clear();
|
||||||
UserStore.clear();
|
UserStore.clear();
|
||||||
TeamStore.clear();
|
TeamStore.clear();
|
||||||
newLocalizationSelected(global.window.mm_config.DefaultClientLocale);
|
newLocalizationSelected(global.window.mm_config.DefaultClientLocale);
|
||||||
browserHistory.push(rURL);
|
browserHistory.push(redirectTo);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
browserHistory.push(rURL);
|
browserHistory.push(redirectTo);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import {loadEmoji} from 'actions/emoji_actions.jsx';
|
|||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import Constants from 'utils/constants.jsx';
|
import Constants from 'utils/constants.jsx';
|
||||||
|
|
||||||
import {browserHistory} from 'react-router/es6';
|
|
||||||
|
|
||||||
const BACKSPACE_CHAR = 8;
|
const BACKSPACE_CHAR = 8;
|
||||||
|
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
@@ -41,7 +39,7 @@ export default class LoggedIn extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('detected logout from a different tab'); //eslint-disable-line no-console
|
console.log('detected logout from a different tab'); //eslint-disable-line no-console
|
||||||
browserHistory.push('/');
|
GlobalActions.emitUserLoggedOutEvent('/', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.originalEvent.key === '__login__' && e.originalEvent.storageArea === localStorage && e.originalEvent.newValue) {
|
if (e.originalEvent.key === '__login__' && e.originalEvent.storageArea === localStorage && e.originalEvent.newValue) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user