From 6d4cac3070add00222589c0429bab34e80ba24d9 Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Thu, 11 Jan 2024 17:30:10 +0200 Subject: [PATCH 1/3] Fix: Frontend is making continuous requests when logout (260) --- .../utm-notification-alert.component.ts | 1 - .../shared/directives/auth/has-any-authority.directive.ts | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/components/layout/header/shared/notification/utm-notification-alert/utm-notification-alert.component.ts b/frontend/src/app/shared/components/layout/header/shared/notification/utm-notification-alert/utm-notification-alert.component.ts index 177774c8e..279026830 100644 --- a/frontend/src/app/shared/components/layout/header/shared/notification/utm-notification-alert/utm-notification-alert.component.ts +++ b/frontend/src/app/shared/components/layout/header/shared/notification/utm-notification-alert/utm-notification-alert.component.ts @@ -42,7 +42,6 @@ export class UtmNotificationAlertComponent implements OnInit, OnDestroy { } ngOnDestroy() { - console.log('destroy'); this.destroy$.next(true); clearInterval(this.timeoutAlert); clearInterval(this.intervalAlert); diff --git a/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts b/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts index 9364b6f59..cfcf33614 100644 --- a/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts +++ b/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts @@ -1,5 +1,6 @@ import {Directive, Input, TemplateRef, ViewContainerRef} from '@angular/core'; import {AccountService} from '../../../core/auth/account.service'; +import {distinctUntilChanged, first} from "rxjs/operators"; /** * @whatItDoes Conditionally includes an HTML element if current user has any @@ -30,7 +31,12 @@ export class HasAnyAuthorityDirective { this.authorities = typeof value === 'string' ? [value] : value; this.updateView(); // Get notified each time authentication state changes. - this.accountService.getAuthenticationState().subscribe(identity => this.updateView()); + this.accountService.getAuthenticationState() + .pipe(distinctUntilChanged((prev, next) => { + // console.log('prev:', prev, 'next:', next); + return prev && next && prev.id === next.id; + })) + .subscribe(identity => this.updateView()); } private updateView(): void { From eacd37cb10bc534cde88b3b1961af7b0205f9dff Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Thu, 11 Jan 2024 17:36:12 +0200 Subject: [PATCH 2/3] Fix: Frontend is making continuous requests when logout (260) --- .../app/shared/directives/auth/has-any-authority.directive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts b/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts index cfcf33614..0ad7bbfdc 100644 --- a/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts +++ b/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts @@ -1,6 +1,6 @@ import {Directive, Input, TemplateRef, ViewContainerRef} from '@angular/core'; +import {distinctUntilChanged} from 'rxjs/operators'; import {AccountService} from '../../../core/auth/account.service'; -import {distinctUntilChanged, first} from "rxjs/operators"; /** * @whatItDoes Conditionally includes an HTML element if current user has any From 439749aaaa1d9ce94ff4587c76538a9e8beeb360 Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Thu, 11 Jan 2024 19:17:59 +0200 Subject: [PATCH 3/3] Fix: Frontend is making continuous requests when logout (260) --- .../shared/directives/auth/has-any-authority.directive.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts b/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts index 0ad7bbfdc..8f9486b69 100644 --- a/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts +++ b/frontend/src/app/shared/directives/auth/has-any-authority.directive.ts @@ -32,10 +32,7 @@ export class HasAnyAuthorityDirective { this.updateView(); // Get notified each time authentication state changes. this.accountService.getAuthenticationState() - .pipe(distinctUntilChanged((prev, next) => { - // console.log('prev:', prev, 'next:', next); - return prev && next && prev.id === next.id; - })) + .pipe(distinctUntilChanged((prev, next) => prev && next && prev.id === next.id)) .subscribe(identity => this.updateView()); }