mirror of https://github.com/abpframework/abp.git
3 changed files with 27 additions and 1 deletions
@ -1,2 +1,3 @@ |
|||||
export * from './oauth.service'; |
export * from './oauth.service'; |
||||
export * from './oauth-error-filter.service'; |
export * from './oauth-error-filter.service'; |
||||
|
export * from './local-storage-listener.service'; |
||||
|
|||||
@ -0,0 +1,19 @@ |
|||||
|
import { DOCUMENT } from '@angular/common'; |
||||
|
import { Injectable, inject } from '@angular/core'; |
||||
|
import { OAuthService } from 'angular-oauth2-oidc'; |
||||
|
|
||||
|
@Injectable({ |
||||
|
providedIn: 'root', |
||||
|
}) |
||||
|
export class LocalStorageListenerService { |
||||
|
protected readonly window = inject(DOCUMENT).defaultView; |
||||
|
protected readonly authService = inject(OAuthService); |
||||
|
|
||||
|
constructor() { |
||||
|
this.window.addEventListener('storage', event => { |
||||
|
if (event.key === 'access_token' && event.newValue === null) { |
||||
|
this.authService.logOut(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue