We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ea9eaec + a6f5c1b commit 8097cf7Copy full SHA for 8097cf7
npm/ng-packs/packages/core/src/lib/services/local-storage-listener.service.ts
@@ -1,6 +1,5 @@
1
import { DOCUMENT } from '@angular/common';
2
import { Injectable, inject } from '@angular/core';
3
-
4
@Injectable({
5
providedIn: 'root',
6
})
@@ -9,8 +8,13 @@ export class LocalStorageListenerService {
9
8
10
constructor() {
11
this.window.addEventListener('storage', event => {
12
- if (event.key === 'access_token' && event.newValue === null) {
13
- this.window.location.reload();
+ if (event.key === 'access_token') {
+ const tokenRemoved = event.newValue === null;
+ const tokenAdded = event.oldValue === null && event.newValue !== null;
14
+
15
+ if (tokenRemoved || tokenAdded) {
16
+ this.window.location.assign('/');
17
+ }
18
}
19
});
20
0 commit comments