Browse Source

Update authentication-state-listener.js

pull/19569/head
liangshiwei 2 years ago
parent
commit
f9eb84cbc0
  1. 18
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js

18
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/authentication-state/authentication-state-listener.js

@ -1,30 +1,30 @@
(function () {
const stateKey = 'authentication-state-id';
window.addEventListener('load', function () {
if (!abp || !abp.currentUser) {
return;
}
if (!abp.currentUser.isAuthenticated){
if (!abp.currentUser.isAuthenticated) {
localStorage.removeItem(stateKey);
}else{
} 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) {
if (event.oldValue || !event.newValue) {
window.location.reload();
}else{
} else {
location.assign('/')
}
});
});
}());
Loading…
Cancel
Save