PLT-4758 fixing signaling of logout (#4984)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
858ce02fc8
Коммит
c81efa0b4e
@@ -4,7 +4,6 @@
|
|||||||
import LoadingScreen from 'components/loading_screen.jsx';
|
import LoadingScreen from 'components/loading_screen.jsx';
|
||||||
|
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
import BrowserStore from 'stores/browser_store.jsx';
|
|
||||||
import PreferenceStore from 'stores/preference_store.jsx';
|
import PreferenceStore from 'stores/preference_store.jsx';
|
||||||
|
|
||||||
import * as GlobalActions from 'actions/global_actions.jsx';
|
import * as GlobalActions from 'actions/global_actions.jsx';
|
||||||
@@ -29,30 +28,6 @@ export default class LoggedIn extends React.Component {
|
|||||||
this.onUserChanged = this.onUserChanged.bind(this);
|
this.onUserChanged = this.onUserChanged.bind(this);
|
||||||
this.setupUser = this.setupUser.bind(this);
|
this.setupUser = this.setupUser.bind(this);
|
||||||
|
|
||||||
// Force logout of all tabs if one tab is logged out
|
|
||||||
$(window).bind('storage', (e) => {
|
|
||||||
// when one tab on a browser logs out, it sets __logout__ in localStorage to trigger other tabs to log out
|
|
||||||
if (e.originalEvent.key === '__logout__' && e.originalEvent.storageArea === localStorage && e.originalEvent.newValue) {
|
|
||||||
// make sure it isn't this tab that is sending the logout signal (only necessary for IE11)
|
|
||||||
if (BrowserStore.isSignallingLogout(e.originalEvent.newValue)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('detected logout from a different tab'); //eslint-disable-line no-console
|
|
||||||
GlobalActions.emitUserLoggedOutEvent('/', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.originalEvent.key === '__login__' && e.originalEvent.storageArea === localStorage && e.originalEvent.newValue) {
|
|
||||||
// make sure it isn't this tab that is sending the logout signal (only necessary for IE11)
|
|
||||||
if (BrowserStore.isSignallingLogin(e.originalEvent.newValue)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('detected login from a different tab'); //eslint-disable-line no-console
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Because current CSS requires the root tag to have specific stuff
|
// Because current CSS requires the root tag to have specific stuff
|
||||||
$('#root').attr('class', 'channel-view');
|
$('#root').attr('class', 'channel-view');
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ import Client from 'client/web_client.jsx';
|
|||||||
import {IntlProvider} from 'react-intl';
|
import {IntlProvider} from 'react-intl';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import FastClick from 'fastclick';
|
import FastClick from 'fastclick';
|
||||||
|
import $ from 'jquery';
|
||||||
|
|
||||||
import {browserHistory} from 'react-router/es6';
|
import {browserHistory} from 'react-router/es6';
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
|
import BrowserStore from 'stores/browser_store.jsx';
|
||||||
|
|
||||||
export default class Root extends React.Component {
|
export default class Root extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -35,6 +36,30 @@ export default class Root extends React.Component {
|
|||||||
}
|
}
|
||||||
/*eslint-enable */
|
/*eslint-enable */
|
||||||
|
|
||||||
|
// Force logout of all tabs if one tab is logged out
|
||||||
|
$(window).bind('storage', (e) => {
|
||||||
|
// when one tab on a browser logs out, it sets __logout__ in localStorage to trigger other tabs to log out
|
||||||
|
if (e.originalEvent.key === '__logout__' && e.originalEvent.storageArea === localStorage && e.originalEvent.newValue) {
|
||||||
|
// make sure it isn't this tab that is sending the logout signal (only necessary for IE11)
|
||||||
|
if (BrowserStore.isSignallingLogout(e.originalEvent.newValue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('detected logout from a different tab'); //eslint-disable-line no-console
|
||||||
|
GlobalActions.emitUserLoggedOutEvent('/', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.originalEvent.key === '__login__' && e.originalEvent.storageArea === localStorage && e.originalEvent.newValue) {
|
||||||
|
// make sure it isn't this tab that is sending the logout signal (only necessary for IE11)
|
||||||
|
if (BrowserStore.isSignallingLogin(e.originalEvent.newValue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('detected login from a different tab'); //eslint-disable-line no-console
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Fastclick
|
// Fastclick
|
||||||
FastClick.attach(document.body);
|
FastClick.attach(document.body);
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user