Browse Source
Merge pull request #22066 from abpframework/issue-18890
Angular - Access token management fixes
pull/22123/head
Yağmur Çelik
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
7 additions and
3 deletions
-
npm/ng-packs/packages/core/src/lib/services/local-storage-listener.service.ts
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
import { DOCUMENT } from '@angular/common'; |
|
|
|
import { Injectable, inject } from '@angular/core'; |
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
providedIn: 'root', |
|
|
|
}) |
|
|
|
@ -9,8 +8,13 @@ export class LocalStorageListenerService { |
|
|
|
|
|
|
|
constructor() { |
|
|
|
this.window.addEventListener('storage', event => { |
|
|
|
if (event.key === 'access_token' && event.newValue === null) { |
|
|
|
this.window.location.reload(); |
|
|
|
if (event.key === 'access_token') { |
|
|
|
const tokenRemoved = event.newValue === null; |
|
|
|
const tokenAdded = event.oldValue === null && event.newValue !== null; |
|
|
|
|
|
|
|
if (tokenRemoved || tokenAdded) { |
|
|
|
this.window.location.assign('/'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|