PLT-1404 signal login to other tags
Этот коммит содержится в:
@@ -29,6 +29,8 @@ class BrowserStoreClass {
|
|||||||
this.checkedLocalStorageSupported = '';
|
this.checkedLocalStorageSupported = '';
|
||||||
this.signalLogout = this.signalLogout.bind(this);
|
this.signalLogout = this.signalLogout.bind(this);
|
||||||
this.isSignallingLogout = this.isSignallingLogout.bind(this);
|
this.isSignallingLogout = this.isSignallingLogout.bind(this);
|
||||||
|
this.signalLogin = this.signalLogin.bind(this);
|
||||||
|
this.isSignallingLogin = this.isSignallingLogin.bind(this);
|
||||||
|
|
||||||
var currentVersion = sessionStorage.getItem('storage_version');
|
var currentVersion = sessionStorage.getItem('storage_version');
|
||||||
if (currentVersion !== global.window.mm_config.Version) {
|
if (currentVersion !== global.window.mm_config.Version) {
|
||||||
@@ -129,6 +131,21 @@ class BrowserStoreClass {
|
|||||||
return logoutId === sessionStorage.getItem('__logout__');
|
return logoutId === sessionStorage.getItem('__logout__');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signalLogin() {
|
||||||
|
if (this.isLocalStorageSupported()) {
|
||||||
|
// PLT-1285 store an identifier in session storage so we can catch if the logout came from this tab on IE11
|
||||||
|
const loginId = generateId();
|
||||||
|
|
||||||
|
sessionStorage.setItem('__login__', loginId);
|
||||||
|
localStorage.setItem('__login__', loginId);
|
||||||
|
localStorage.removeItem('__login__');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isSignallingLogin(loginId) {
|
||||||
|
return loginId === sessionStorage.getItem('__login__');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preforms the given action on each item that has the given prefix
|
* Preforms the given action on each item that has the given prefix
|
||||||
* Signature for action is action(key, value)
|
* Signature for action is action(key, value)
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ export function loginByEmail(name, email, password, success, error) {
|
|||||||
data: JSON.stringify({name: name, email: email, password: password}),
|
data: JSON.stringify({name: name, email: email, password: password}),
|
||||||
success: function onSuccess(data, textStatus, xhr) {
|
success: function onSuccess(data, textStatus, xhr) {
|
||||||
track('api', 'api_users_login_success', data.team_id, 'email', data.email);
|
track('api', 'api_users_login_success', data.team_id, 'email', data.email);
|
||||||
|
BrowserStore.signalLogin();
|
||||||
success(data, textStatus, xhr);
|
success(data, textStatus, xhr);
|
||||||
},
|
},
|
||||||
error: function onError(xhr, status, err) {
|
error: function onError(xhr, status, err) {
|
||||||
|
|||||||
@@ -68,6 +68,16 @@
|
|||||||
console.log('detected logout from a different tab');
|
console.log('detected logout from a different tab');
|
||||||
window.location.href = '/' + window.mm_team.name;
|
window.location.href = '/' + window.mm_team.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 (window.BrowserStore.isSignallingLogin(e.originalEvent.newValue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('detected login from a different tab');
|
||||||
|
window.location.href = '/';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user