From b716bf679d5adf4de0983eec247ad3708df28bda Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Mon, 17 Jun 2024 14:26:32 +0300 Subject: [PATCH] added reload other tabs logic when merging or unlinking accounts --- .../app/core/services/auth/auth.service.ts | 6 ++++ .../merge-email-confirmation.component.ts | 28 ++++++++++--------- .../unlink-email-confirmation.component.ts | 15 ++++++---- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index d4451150e..5d0da720b 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -74,6 +74,12 @@ export class AuthService extends BaseService { ) { this.selectedTenant(event.newValue); window.location.href = this.tenantHandlingService.getCurrentUrlEnrichedWithTenantCode(event.newValue, true); + } else if ( + event.key && + event.key === 'refreshPage' && + event.newValue == 'true' + ) { + window.location.reload(); } }); } diff --git a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts index 5fb14eff8..f5fcc3ab0 100644 --- a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts @@ -41,15 +41,15 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit { const token = params['token'] if (token != null) { this.userService.getUserTokenPermission(token) - .subscribe(result => { - this.isTokenValid = result - this.token = token; - }, error => { - this.token = Guid.createEmpty(); - this.onCallbackError(error); - }); + .subscribe(result => { + this.isTokenValid = result + this.token = token; + }, error => { + this.token = Guid.createEmpty(); + this.onCallbackError(error); + }); } - }); + }); } onConfirm(): void { @@ -61,14 +61,16 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit { this.onCallbackEmailConfirmationSuccess(); } }, - error => this.onCallbackError(error)); + error => this.onCallbackError(error)); } onCallbackEmailConfirmationSuccess() { this.router.navigate([this.routerUtils.generateUrl('home')]) - .then(() => { - window.location.reload(); - }); + .then(() => { + localStorage.setItem('refreshPage', null); + localStorage.setItem('refreshPage', 'true'); + window.location.reload(); + }); } onCallbackError(errorResponse: HttpErrorResponse) { @@ -76,7 +78,7 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit { errorOverrides.set(302, this.language.instant('EMAIL-CONFIRMATION.EMAIL-FOUND')); errorOverrides.set(403, this.language.instant('EMAIL-CONFIRMATION.EXPIRED-EMAIL')); this.httpErrorHandlingService.handleBackedRequestError(errorResponse, errorOverrides, SnackBarNotificationLevel.Error) - + const error: HttpError = this.httpErrorHandlingService.getError(errorResponse); if (error.statusCode === 302) { this.router.navigate([this.routerUtils.generateUrl('home')]); diff --git a/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts b/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts index d5b46eb63..36bfb83ec 100644 --- a/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts @@ -10,8 +10,8 @@ import { TranslateService } from '@ngx-translate/core'; import { takeUntil } from "rxjs/operators"; @Component({ - selector: 'app-unlink-email-confirmation-component', - templateUrl: './unlink-email-confirmation.component.html' + selector: 'app-unlink-email-confirmation-component', + templateUrl: './unlink-email-confirmation.component.html' }) export class UnlinkEmailConfirmation extends BaseComponent implements OnInit { private token: Guid; @@ -50,11 +50,16 @@ export class UnlinkEmailConfirmation extends BaseComponent implements OnInit { this.onCallbackConfirmationSuccess(); } }, - error => this.onCallbackError(error)); + error => this.onCallbackError(error)); } onCallbackConfirmationSuccess() { - this.router.navigate([this.routerUtils.generateUrl('home')]); + this.router.navigate([this.routerUtils.generateUrl('home')]) + .then(() => { + localStorage.setItem('refreshPage', null); + localStorage.setItem('refreshPage', 'true'); + window.location.reload(); + }); } onCallbackError(errorResponse: HttpErrorResponse) { @@ -63,7 +68,7 @@ export class UnlinkEmailConfirmation extends BaseComponent implements OnInit { errorOverrides.set(302, this.language.instant('EMAIL-CONFIRMATION.EMAIL-FOUND')); errorOverrides.set(-1, this.language.instant('EMAIL-CONFIRMATION.EXPIRED-EMAIL')); this.httpErrorHandlingService.handleBackedRequestError(errorResponse, errorOverrides) - + const error: HttpError = this.httpErrorHandlingService.getError(errorResponse); if (error.statusCode === 302) { this.router.navigate([this.routerUtils.generateUrl('home')]);