From 5decf6f4b1b6145dc43910326d83d220d5c1d259 Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Thu, 4 Apr 2024 13:50:51 +0300 Subject: [PATCH] login with the default tenant --- .../src/app/core/services/auth/auth.service.ts | 2 +- dmp-frontend/src/app/ui/auth/login/login.component.ts | 11 ++++++----- .../http/interceptors/status-code.interceptor.ts | 4 ++-- 3 files changed, 9 insertions(+), 8 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 38531c729..762aff749 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -272,7 +272,7 @@ export class AuthService extends BaseService { }) .catch((error) => this.onAuthenticateError(error)); } else { - this.zone.run(() => this.router.navigate(['/login/post'])); + this.zone.run(() => this.router.navigate([returnUrl])); } }); } diff --git a/dmp-frontend/src/app/ui/auth/login/login.component.ts b/dmp-frontend/src/app/ui/auth/login/login.component.ts index d87d863fb..bd00ef0d2 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.component.ts @@ -29,22 +29,23 @@ export class LoginComponent extends BaseComponent implements OnInit { ) { super(); } ngOnInit(): void { - this.returnUrl = this.route.snapshot.queryParamMap.get('returnUrl') || '/login/post'; + this.returnUrl = this.route.snapshot.queryParamMap.get('returnUrl') || '/'; this.keycloakService.isLoggedIn().then(isLoggedIn => { if (!isLoggedIn) { - this.authService.authenticate('/login/post'); + this.authService.authenticate('/'); } else { this.authService.prepareAuthRequest(from(this.keycloakService.getToken())).pipe(takeUntil(this._destroyed)).subscribe( () => { let returnUrL = this.returnUrl; let queryParams: Params = {}; if(!this.authService.selectedTenant()){ - returnUrL = '/login/post'; - queryParams.returnUrl = this.returnUrl; + this.authService.selectedTenant('default'); + // returnUrL = '/login/post'; + // queryParams.returnUrl = this.returnUrl; } this.zone.run(() => this.router.navigate([returnUrL],{queryParams} )); }, - (error) => this.authService.authenticate('/login/post') ); + (error) => this.authService.authenticate('/') ); } diff --git a/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts b/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts index d83bb4a4f..809659444 100644 --- a/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts @@ -21,8 +21,8 @@ export class StatusCodeInterceptor extends BaseInterceptor { } const error: HttpError = this.httpErrorHandlingService.getError(err); if (error.statusCode === 403 && error.errorCode === 103) { - this.authService.selectedTenant(null); - this.router.navigate(['/login/post']); + this.authService.selectedTenant('default'); + this.router.navigate(['/']); } })); }