Browse Source
Merge pull request #19489 from abpframework/issue-19488
Add `LocalStorageListenerService` to logout from other tabs
pull/19565/head
oykuermann
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
26 additions and
1 deletions
-
npm/ng-packs/packages/core/src/lib/core.module.ts
-
npm/ng-packs/packages/core/src/lib/services/index.ts
-
npm/ng-packs/packages/core/src/lib/services/local-storage-listener.service.ts
|
|
|
@ -43,6 +43,7 @@ import { AuthErrorFilterService } from './abstracts'; |
|
|
|
import { DYNAMIC_LAYOUTS_TOKEN } from "./tokens/dynamic-layout.token"; |
|
|
|
import { DEFAULT_DYNAMIC_LAYOUTS } from "./constants"; |
|
|
|
import { AbpTitleStrategy } from './services/title-strategy.service'; |
|
|
|
import { LocalStorageListenerService } from './services/local-storage-listener.service'; |
|
|
|
|
|
|
|
|
|
|
|
const standaloneDirectives = [ |
|
|
|
@ -164,6 +165,12 @@ export class CoreModule { |
|
|
|
deps: [LocalizationService], |
|
|
|
useFactory: noop, |
|
|
|
}, |
|
|
|
{ |
|
|
|
provide: APP_INITIALIZER, |
|
|
|
multi: true, |
|
|
|
deps: [LocalStorageListenerService], |
|
|
|
useFactory: noop, |
|
|
|
}, |
|
|
|
{ |
|
|
|
provide: APP_INITIALIZER, |
|
|
|
multi: true, |
|
|
|
|
|
|
|
@ -20,4 +20,5 @@ export * from './subscription.service'; |
|
|
|
export * from './track-by.service'; |
|
|
|
export * from './local-storage.service'; |
|
|
|
export * from './window.service'; |
|
|
|
export * from './internet-connection-service' |
|
|
|
export * from './internet-connection-service'; |
|
|
|
export * from './local-storage-listener.service'; |
|
|
|
|
|
|
|
@ -0,0 +1,17 @@ |
|
|
|
import { DOCUMENT } from '@angular/common'; |
|
|
|
import { Injectable, inject } from '@angular/core'; |
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
providedIn: 'root', |
|
|
|
}) |
|
|
|
export class LocalStorageListenerService { |
|
|
|
protected readonly window = inject(DOCUMENT).defaultView; |
|
|
|
|
|
|
|
constructor() { |
|
|
|
this.window.addEventListener('storage', event => { |
|
|
|
if (event.key === 'access_token' && event.newValue === null) { |
|
|
|
this.window.location.reload(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |