mirror of https://github.com/abpframework/abp.git
Browse Source
Add authentication-state-listener js to logout from other tabs for MVC UIpull/19579/head
committed by
GitHub
3 changed files with 33 additions and 2 deletions
@ -0,0 +1,30 @@ |
|||
(function () { |
|||
|
|||
const stateKey = 'authentication-state-id'; |
|||
|
|||
window.addEventListener('load', function () { |
|||
if (!abp || !abp.currentUser) { |
|||
return; |
|||
} |
|||
|
|||
if (!abp.currentUser.isAuthenticated) { |
|||
localStorage.removeItem(stateKey); |
|||
} else { |
|||
localStorage.setItem(stateKey, abp.currentUser.id); |
|||
} |
|||
|
|||
window.addEventListener('storage', function (event) { |
|||
|
|||
if (event.key !== stateKey || event.oldValue === event.newValue) { |
|||
return; |
|||
} |
|||
|
|||
if (event.oldValue || !event.newValue) { |
|||
window.location.reload(); |
|||
} else { |
|||
location.assign('/') |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
}()); |
|||
Loading…
Reference in new issue