diff --git a/package-lock.json b/package-lock.json index 387f0eb8b..419203abb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@angular/platform-browser-dynamic": "^19.1.3", "@angular/router": "^19.1.3", "@egjs/hammerjs": "^2.0.17", - "@geoengine/openapi-client": "0.0.19", + "@geoengine/openapi-client": "0.0.20", "codemirror": "~5.65.18", "d3": "~7.9.0", "dagre": "~0.8.5", @@ -3494,9 +3494,9 @@ } }, "node_modules/@geoengine/openapi-client": { - "version": "0.0.19", - "resolved": "https://registry.npmjs.org/@geoengine/openapi-client/-/openapi-client-0.0.19.tgz", - "integrity": "sha512-oi1k3NbP1J63bmWVo9JCIqevWu5UaEkm+OKTZEA9J8yUe1InD6rW6iVyj6Fj9MOwpa9oi9PkVnbT1lZJd6f5qA==" + "version": "0.0.20", + "resolved": "https://registry.npmjs.org/@geoengine/openapi-client/-/openapi-client-0.0.20.tgz", + "integrity": "sha512-GN5wMMvTM31nN15EBjQn3E3er9u1urPzO8iGOAFEwnHGUP+YSoIgduy7gq13f63QmDL8GnggvHuZC5bmN9+w+w==" }, "node_modules/@humanfs/core": { "version": "0.19.1", diff --git a/package.json b/package.json index 166687f72..12d0942b0 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@angular/platform-browser-dynamic": "^19.1.3", "@angular/router": "^19.1.3", "@egjs/hammerjs": "^2.0.17", - "@geoengine/openapi-client": "0.0.19", + "@geoengine/openapi-client": "0.0.20", "codemirror": "~5.65.18", "d3": "~7.9.0", "dagre": "~0.8.5", diff --git a/projects/common/src/lib/login/login.component.ts b/projects/common/src/lib/login/login.component.ts index 6f51ffa36..2568b7caf 100644 --- a/projects/common/src/lib/login/login.component.ts +++ b/projects/common/src/lib/login/login.component.ts @@ -59,8 +59,10 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy { } ngOnInit(): void { + const redirectUri = window.location.href.replace(/\/signin$/, this.loginRedirect()); + // check if OIDC login is enabled - this.userService.oidcInit().subscribe( + this.userService.oidcInit(redirectUri).subscribe( (idr) => { this.oidcUrl = idr.url; this.formStatus$.next(FormStatus.Oidc); @@ -98,7 +100,7 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy { oidcLogin(): void { this.formStatus$.next(FormStatus.Loading); - window.location.href = this.oidcUrl + '&redirect_url=' + window.location.href.replace(/\/signin$/, this.loginRedirect()); + window.location.href = this.oidcUrl; } login(): void { diff --git a/projects/common/src/lib/user/user.service.ts b/projects/common/src/lib/user/user.service.ts index 01164a94d..2fc616555 100644 --- a/projects/common/src/lib/user/user.service.ts +++ b/projects/common/src/lib/user/user.service.ts @@ -127,7 +127,7 @@ export class UserService { this.sessionInitialized = true; - if (oidcParams) { + if (oidcParams && sessionStorage.getItem('redirectUri')) { this.oidcLogin(oidcParams) .pipe(first()) .subscribe(() => { @@ -343,8 +343,14 @@ export class UserService { this.logoutCallback = callback; } - oidcInit(): Observable { - return from(new SessionApi().oidcInit()); + oidcInit(redirectUri: string): Observable { + sessionStorage.setItem('redirectUri', redirectUri); + + return from( + new SessionApi().oidcInit({ + redirectUri: redirectUri, + }), + ); } oidcLogin(request: {sessionState: string; code: string; state: string}): Observable { @@ -353,12 +359,14 @@ export class UserService { new SessionApi() .oidcLogin({ authCodeResponse: request, + redirectUri: sessionStorage.getItem('redirectUri')!, }) .then((response) => { const session = this.sessionFromDict(response); this.session$.next(session); result.next(session); result.complete(); + sessionStorage.removeItem('redirectUri'); }) .catch((error) => result.error(error)); diff --git a/projects/core/src/lib/users/oidc/oidc.component.ts b/projects/core/src/lib/users/oidc/oidc.component.ts index 948dd3520..adb05b5ad 100644 --- a/projects/core/src/lib/users/oidc/oidc.component.ts +++ b/projects/core/src/lib/users/oidc/oidc.component.ts @@ -44,7 +44,7 @@ export class OidcComponent implements OnInit, OnDestroy { this.pendingLoginRequest = true; this.loginDisabled.next(true); this.loginSubscription = this.userService - .oidcInit() + .oidcInit(window.location.href) .pipe( first(), finalize(() => { diff --git a/projects/dashboards/esg-indicator-service/src/app/login/login.component.ts b/projects/dashboards/esg-indicator-service/src/app/login/login.component.ts index 9e68a0d8c..17244a034 100644 --- a/projects/dashboards/esg-indicator-service/src/app/login/login.component.ts +++ b/projects/dashboards/esg-indicator-service/src/app/login/login.component.ts @@ -56,8 +56,10 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy { } ngOnInit(): void { + const redirectUri = window.location.href.replace(/\/signin$/, '/dashboard'); + // check if OIDC login is enabled - this.userService.oidcInit().subscribe( + this.userService.oidcInit(redirectUri).subscribe( (idr) => { this.oidcUrl = idr.url; this.formStatus$.next(FormStatus.Oidc); diff --git a/projects/dashboards/gfbio/src/app/app.component.ts b/projects/dashboards/gfbio/src/app/app.component.ts index b24afe910..0b972be4c 100644 --- a/projects/dashboards/gfbio/src/app/app.component.ts +++ b/projects/dashboards/gfbio/src/app/app.component.ts @@ -273,7 +273,7 @@ export class AppComponent implements OnInit, AfterViewInit { const state = params.get('state'); let login; - if (sessionState && code && state) { + if (sessionState && code && state && sessionStorage.getItem('redirectUri')) { login = this.userService.oidcLogin({sessionState, code, state}).pipe(first()); }