From cab74246d680d089377fe6c25a21f3a631d263d5 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:29:50 +0100 Subject: [PATCH 01/11] feat: add logout url logic --- apps/metadata-editor/src/app/app.module.ts | 5 +++++ conf/default.toml | 1 + .../repository/src/lib/gn4/auth/auth.service.ts | 14 +++++++++++--- libs/util/app-config/src/lib/app-config.ts | 2 ++ libs/util/app-config/src/lib/fixtures.ts | 1 + libs/util/app-config/src/lib/model.ts | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/metadata-editor/src/app/app.module.ts b/apps/metadata-editor/src/app/app.module.ts index 87354808bc..c2a3784725 100644 --- a/apps/metadata-editor/src/app/app.module.ts +++ b/apps/metadata-editor/src/app/app.module.ts @@ -26,6 +26,7 @@ import { DashboardPageComponent } from './dashboard/dashboard-page.component' import { EditorRouterService } from './router.service' import { LOGIN_URL, + LOGOUT_URL, provideGn4, provideRepositoryUrl, } from '@geonetwork-ui/api/repository' @@ -70,6 +71,10 @@ import { FeatureEditorModule } from '@geonetwork-ui/feature/editor' provide: LOGIN_URL, useFactory: () => getGlobalConfig().LOGIN_URL, }, + { + provide: LOGOUT_URL, + useFactory: () => getGlobalConfig().LOGOUT_URL, + }, ], bootstrap: [AppComponent], }) diff --git a/conf/default.toml b/conf/default.toml index 0cd7d309d6..cdd3ade555 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -23,6 +23,7 @@ proxy_path = "" # - ${lang2}, ${lang3}: indicates if and where the current language should be part of the login URL in language 2 or 3 letter code # Example to use the georchestra login page: # login_url = "/cas/login?service=${current_url}" +# logout_url = "/geonetwork/signout?redirectUrl=\${current_url}" # This optional URL should point to the static html page wc-embedder.html which allows to display a web component (like chart and table) via a permalink. # URLs can be indicated from the root of the same server starting with a "/" or as an external URL. Be conscious of potential CORS issues when using an external URL. # The default location in the dockerized datahub app for example is "/datahub/wc-embedder.html". diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.ts index fae24500ba..e564950a44 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.ts @@ -5,11 +5,15 @@ import { TranslateService } from '@ngx-translate/core' export const DEFAULT_GN4_LOGIN_URL = `/geonetwork/srv/\${lang3}/catalog.signin?redirect=\${current_url}` export const LOGIN_URL = new InjectionToken('loginUrl') +export const DEFAULT_GN4_LOGOUT_URL = `/geonetwork/signout` +export const LOGOUT_URL = new InjectionToken('loginUrl') + @Injectable({ providedIn: 'root', }) export class AuthService { baseLoginUrl = this.baseLoginUrlToken || DEFAULT_GN4_LOGIN_URL + baseLogoutUrl = this.baseLogoutUrlToken || DEFAULT_GN4_LOGOUT_URL get loginUrl() { let baseUrl = this.baseLoginUrl const locationHasQueryParams = !!window.location.search @@ -25,10 +29,14 @@ export class AuthService { LANG_2_TO_3_MAPPER[this.translateService.currentLang] ) } + + get logoutUrl() { + return this.baseLogoutUrl + } + constructor( - @Optional() - @Inject(LOGIN_URL) - private baseLoginUrlToken: string, + @Optional() @Inject(LOGIN_URL) private baseLoginUrlToken: string, + @Optional() @Inject(LOGOUT_URL) private baseLogoutUrlToken: string, private translateService: TranslateService ) {} } diff --git a/libs/util/app-config/src/lib/app-config.ts b/libs/util/app-config/src/lib/app-config.ts index 04ca6b87fd..540073903c 100644 --- a/libs/util/app-config/src/lib/app-config.ts +++ b/libs/util/app-config/src/lib/app-config.ts @@ -98,6 +98,7 @@ export function loadAppConfig() { 'proxy_path', 'metadata_language', 'login_url', + 'logout_url', 'web_component_embedder_url', 'languages', 'contact_email', @@ -124,6 +125,7 @@ export function loadAppConfig() { ).toLowerCase() : undefined, LOGIN_URL: parsedGlobalSection.login_url, + LOGOUT_URL: parsedGlobalSection.logout_url, WEB_COMPONENT_EMBEDDER_URL: parsedGlobalSection.web_component_embedder_url, LANGUAGES: parsedGlobalSection.languages, diff --git a/libs/util/app-config/src/lib/fixtures.ts b/libs/util/app-config/src/lib/fixtures.ts index 2a7cec35d4..731ce788e3 100644 --- a/libs/util/app-config/src/lib/fixtures.ts +++ b/libs/util/app-config/src/lib/fixtures.ts @@ -6,6 +6,7 @@ geonetwork4_api_url = "/geonetwork/srv/api" proxy_path = "/proxy/?url=" metadata_language = "fre" login_url = "/cas/login?service=" +logout_url = "/geonetwork/signout?redirectUrl=" web_component_embedder_url = "/datahub/wc-embedder.html" [map] diff --git a/libs/util/app-config/src/lib/model.ts b/libs/util/app-config/src/lib/model.ts index 84682b6eee..742aa7fc4b 100644 --- a/libs/util/app-config/src/lib/model.ts +++ b/libs/util/app-config/src/lib/model.ts @@ -6,6 +6,7 @@ export interface GlobalConfig { PROXY_PATH?: string METADATA_LANGUAGE?: string LOGIN_URL?: string + LOGOUT_URL?: string WEB_COMPONENT_EMBEDDER_URL?: string LANGUAGES?: string[] CONTACT_EMAIL?: string From c22bf1c8309886a58ea323f3ad7e4cf986fb25f8 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:30:19 +0100 Subject: [PATCH 02/11] feat: implement logout in sidebar --- .../dashboard/sidebar/sidebar.component.html | 8 ++++++- .../dashboard/sidebar/sidebar.component.ts | 24 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html index 0c81c789b8..8491a2091f 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html @@ -31,8 +31,14 @@ - Log out + Log out diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts index 0aeb4afca0..8c662165b2 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts @@ -3,7 +3,10 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core' import { TranslateModule } from '@ngx-translate/core' import { DashboardMenuComponent } from '../dashboard-menu/dashboard-menu.component' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' -import { AvatarServiceInterface } from '@geonetwork-ui/api/repository' +import { + AuthService, + AvatarServiceInterface, +} from '@geonetwork-ui/api/repository' import { LetDirective } from '@ngrx/component' import { UiElementsModule } from '@geonetwork-ui/ui/elements' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' @@ -31,7 +34,8 @@ export class SidebarComponent implements OnInit { constructor( public platformService: PlatformServiceInterface, private avatarService: AvatarServiceInterface, - public organisationsService: OrganizationsServiceInterface + public organisationsService: OrganizationsServiceInterface, + private authService: AuthService ) {} ngOnInit(): void { @@ -41,4 +45,20 @@ export class SidebarComponent implements OnInit { (orgs, me) => orgs.filter((org) => org.name === me?.organisation) ) } + + logOut() { + fetch(this.authService.logoutUrl, { + method: 'GET', + }) + .then((response) => { + if (response.ok) { + window.location.href = 'http://localhost:4200' + } else { + console.error('Logout failed') + } + }) + .catch((error) => { + console.error('Error during logout request:', error) + }) + } } From b514139704633f0ad207f62dc5db99bfaa25dd2f Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:30:31 +0100 Subject: [PATCH 03/11] feat: add ut and e2e --- .../src/e2e/dashboard.cy.ts | 22 ++++++++--- .../sidebar/sidebar.component.spec.ts | 37 ++++++++++++++++++- .../src/lib/gn4/auth/auth.service.spec.ts | 9 +++++ 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts index 5cee3c2b69..91b7df4e7d 100644 --- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts @@ -344,11 +344,23 @@ describe('dashboard (authenticated)', () => { }) }) -describe('when the user is not logged in', () => { - beforeEach(() => { - cy.visit('/catalog/search') +describe('Logging in and out', () => { + describe('when the user is not logged in', () => { + beforeEach(() => { + cy.visit('/catalog/search') + }) + it('redirects to the login page', () => { + cy.url().should('include', '/catalog.signin?redirect=') + }) }) - it('redirects to the login page', () => { - cy.url().should('include', '/catalog.signin?redirect=') + describe('Logging out', () => { + beforeEach(() => { + cy.login('admin', 'admin', false) + cy.visit('/catalog/search') + }) + it('logs out the user', () => { + cy.get('md-editor-sidebar').find('gn-ui-button').eq(1).click() + cy.url().should('include', '/catalog.signin?redirect=') + }) }) }) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts index 50982f3777..2bda7b2737 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts @@ -1,19 +1,27 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' -import { AvatarServiceInterface } from '@geonetwork-ui/api/repository' +import { + AuthService, + AvatarServiceInterface, +} from '@geonetwork-ui/api/repository' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' import { TranslateModule } from '@ngx-translate/core' -import { MockBuilder, MockProviders } from 'ng-mocks' +import { MockBuilder, MockProvider, MockProviders } from 'ng-mocks' import { SidebarComponent } from './sidebar.component' describe('SidebarComponent', () => { let component: SidebarComponent let fixture: ComponentFixture + let service: AuthService beforeEach(() => { return MockBuilder(SidebarComponent) }) + afterEach(() => { + jest.resetAllMocks() + }) + beforeEach(async () => { await TestBed.configureTestingModule({ imports: [SidebarComponent, TranslateModule.forRoot()], @@ -23,9 +31,13 @@ describe('SidebarComponent', () => { AvatarServiceInterface, OrganizationsServiceInterface ), + MockProvider(AuthService, { + logoutUrl: 'http://logout.com/bla?', + }), ], }).compileComponents() + service = TestBed.inject(AuthService) fixture = TestBed.createComponent(SidebarComponent) component = fixture.componentInstance fixture.detectChanges() @@ -34,4 +46,25 @@ describe('SidebarComponent', () => { it('should create', () => { expect(component).toBeTruthy() }) + + describe('logOut', () => { + it('should log out', async () => { + jest.spyOn(window, 'fetch').mockResolvedValue({ + ok: true, + } as Response) + + delete window.location + Object.defineProperty(window, 'location', { + value: { href: 'http://app-url.com' }, + writable: true, + }) + + await component.logOut() + + expect(window.fetch).toHaveBeenCalledWith(service.logoutUrl, { + method: 'GET', + }) + expect(window.location.href).toBe('http://localhost:4200') + }) + }) }) diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts index f604788788..dabc434e34 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts @@ -82,4 +82,13 @@ describe('AuthService', () => { ) }) }) + + describe('Logout', () => { + beforeEach(() => { + service = TestBed.inject(AuthService) + }) + it('should return the logout url', () => { + expect(service.logoutUrl).toEqual('/geonetwork/signout') + }) + }) }) From cd1cb3590536e314c9ef2b347a6437d0d638374e Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 15:30:43 +0100 Subject: [PATCH 04/11] feat: add translations --- translations/de.json | 1 + translations/en.json | 1 + translations/es.json | 1 + translations/fr.json | 1 + translations/it.json | 1 + translations/nl.json | 1 + translations/pt.json | 1 + translations/sk.json | 1 + 8 files changed, 8 insertions(+) diff --git a/translations/de.json b/translations/de.json index 63d5ec7762..00ae56f652 100644 --- a/translations/de.json +++ b/translations/de.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "Dieser Datensatz ist auf dem neuesten Stand", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "Datensatz aus dem Datahub", diff --git a/translations/en.json b/translations/en.json index 3f15cfe258..f4c7e19558 100644 --- a/translations/en.json +++ b/translations/en.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "There are no pending changes on this record", "editor.record.undo.tooltip.enabled": "Clicking this button will cancel the pending changes on this record.", "editor.record.upToDate": "This record is up to date", + "editor.sidebar.logout": "Log out", "editor.sidebar.menu.editor": "Editor", "editor.temporary.disabled": "Not implemented yet", "externalviewer.dataset.unnamed": "Datahub layer", diff --git a/translations/es.json b/translations/es.json index 10e1c8cb55..12e2cba9ce 100644 --- a/translations/es.json +++ b/translations/es.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", diff --git a/translations/fr.json b/translations/fr.json index a12538009c..ba4da4eef8 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "Il n'y a pas de modifications en cours sur cette fiche", "editor.record.undo.tooltip.enabled": "Cliquez sur ce bouton pour annuler les modifications apportées à cette fiche", "editor.record.upToDate": "", + "editor.sidebar.logout": "Se déconnecter", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "Pas encore implémenté", "externalviewer.dataset.unnamed": "Couche du datahub", diff --git a/translations/it.json b/translations/it.json index ed95d6c683..272d8d2da0 100644 --- a/translations/it.json +++ b/translations/it.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "Layer del datahub", diff --git a/translations/nl.json b/translations/nl.json index 1c50db16cd..fc38f38858 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", diff --git a/translations/pt.json b/translations/pt.json index 3d48db46d9..4a412c2691 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", diff --git a/translations/sk.json b/translations/sk.json index cb11870799..bef5dc3a42 100644 --- a/translations/sk.json +++ b/translations/sk.json @@ -296,6 +296,7 @@ "editor.record.undo.tooltip.disabled": "", "editor.record.undo.tooltip.enabled": "", "editor.record.upToDate": "", + "editor.sidebar.logout": "", "editor.sidebar.menu.editor": "", "editor.temporary.disabled": "", "externalviewer.dataset.unnamed": "", From ab0d566677940d2a0acbb90c5c9853fade1c100a Mon Sep 17 00:00:00 2001 From: cmoinier Date: Thu, 14 Nov 2024 16:33:00 +0100 Subject: [PATCH 05/11] fix: add logout url in ut fixture --- libs/util/app-config/src/lib/app-config.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/util/app-config/src/lib/app-config.spec.ts b/libs/util/app-config/src/lib/app-config.spec.ts index e590d8a9ad..c943624127 100644 --- a/libs/util/app-config/src/lib/app-config.spec.ts +++ b/libs/util/app-config/src/lib/app-config.spec.ts @@ -133,6 +133,7 @@ describe('app config utils', () => { PROXY_PATH: '/proxy/?url=', METADATA_LANGUAGE: 'fre', LOGIN_URL: '/cas/login?service=', + LOGOUT_URL: '/geonetwork/signout?redirectUrl=', WEB_COMPONENT_EMBEDDER_URL: '/datahub/wc-embedder.html', }) }) From 07f9e57d1913d1a5baebc33de87e34bdf853b526 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Fri, 15 Nov 2024 08:16:22 +0100 Subject: [PATCH 06/11] feat: shorten logout urls --- conf/default.toml | 2 +- libs/util/app-config/src/lib/app-config.spec.ts | 2 +- libs/util/app-config/src/lib/fixtures.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/default.toml b/conf/default.toml index cdd3ade555..bae70b32dc 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -23,7 +23,7 @@ proxy_path = "" # - ${lang2}, ${lang3}: indicates if and where the current language should be part of the login URL in language 2 or 3 letter code # Example to use the georchestra login page: # login_url = "/cas/login?service=${current_url}" -# logout_url = "/geonetwork/signout?redirectUrl=\${current_url}" +# logout_url = "/geonetwork/signout" # This optional URL should point to the static html page wc-embedder.html which allows to display a web component (like chart and table) via a permalink. # URLs can be indicated from the root of the same server starting with a "/" or as an external URL. Be conscious of potential CORS issues when using an external URL. # The default location in the dockerized datahub app for example is "/datahub/wc-embedder.html". diff --git a/libs/util/app-config/src/lib/app-config.spec.ts b/libs/util/app-config/src/lib/app-config.spec.ts index c943624127..53b05d6bfa 100644 --- a/libs/util/app-config/src/lib/app-config.spec.ts +++ b/libs/util/app-config/src/lib/app-config.spec.ts @@ -133,7 +133,7 @@ describe('app config utils', () => { PROXY_PATH: '/proxy/?url=', METADATA_LANGUAGE: 'fre', LOGIN_URL: '/cas/login?service=', - LOGOUT_URL: '/geonetwork/signout?redirectUrl=', + LOGOUT_URL: '/geonetwork/signout', WEB_COMPONENT_EMBEDDER_URL: '/datahub/wc-embedder.html', }) }) diff --git a/libs/util/app-config/src/lib/fixtures.ts b/libs/util/app-config/src/lib/fixtures.ts index 731ce788e3..3126cb0492 100644 --- a/libs/util/app-config/src/lib/fixtures.ts +++ b/libs/util/app-config/src/lib/fixtures.ts @@ -6,7 +6,7 @@ geonetwork4_api_url = "/geonetwork/srv/api" proxy_path = "/proxy/?url=" metadata_language = "fre" login_url = "/cas/login?service=" -logout_url = "/geonetwork/signout?redirectUrl=" +logout_url = "/geonetwork/signout" web_component_embedder_url = "/datahub/wc-embedder.html" [map] From ca25e5870b9383c656503b2a503cfdae7f964b3a Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:44:35 +0100 Subject: [PATCH 07/11] fix: use actual host instead --- .../src/app/dashboard/sidebar/sidebar.component.spec.ts | 8 ++------ .../src/app/dashboard/sidebar/sidebar.component.ts | 3 ++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts index 2bda7b2737..15419cda92 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts @@ -53,18 +53,14 @@ describe('SidebarComponent', () => { ok: true, } as Response) - delete window.location - Object.defineProperty(window, 'location', { - value: { href: 'http://app-url.com' }, - writable: true, - }) + const originalUrl = window.location.href await component.logOut() expect(window.fetch).toHaveBeenCalledWith(service.logoutUrl, { method: 'GET', }) - expect(window.location.href).toBe('http://localhost:4200') + expect(window.location.href).toBe(originalUrl) }) }) }) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts index 8c662165b2..53fc909f64 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts @@ -47,12 +47,13 @@ export class SidebarComponent implements OnInit { } logOut() { + const current_url = window.location.toString() fetch(this.authService.logoutUrl, { method: 'GET', }) .then((response) => { if (response.ok) { - window.location.href = 'http://localhost:4200' + window.location.href = current_url } else { console.error('Logout failed') } From 69c6f3dfcb1b785acaff8827a63134fcb61ba87b Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:45:27 +0100 Subject: [PATCH 08/11] fix: change token name --- libs/api/repository/src/lib/gn4/auth/auth.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.ts index e564950a44..667e817aa3 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.ts @@ -6,7 +6,7 @@ export const DEFAULT_GN4_LOGIN_URL = `/geonetwork/srv/\${lang3}/catalog.signin?r export const LOGIN_URL = new InjectionToken('loginUrl') export const DEFAULT_GN4_LOGOUT_URL = `/geonetwork/signout` -export const LOGOUT_URL = new InjectionToken('loginUrl') +export const LOGOUT_URL = new InjectionToken('logoutUrl') @Injectable({ providedIn: 'root', From 9aae01902b36388f7b456a51af4db22a7c077490 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:45:47 +0100 Subject: [PATCH 09/11] fix: add avatar-based logout test --- apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts index 91b7df4e7d..47132f26e7 100644 --- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts @@ -359,8 +359,10 @@ describe('Logging in and out', () => { cy.visit('/catalog/search') }) it('logs out the user', () => { + cy.get('gn-ui-avatar').should('be.visible') cy.get('md-editor-sidebar').find('gn-ui-button').eq(1).click() cy.url().should('include', '/catalog.signin?redirect=') + cy.get('gn-ui-avatar').should('not.exist') }) }) }) From 562d37e0795e4bd47894f889899a2869de2156ad Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 18 Nov 2024 14:47:46 +0100 Subject: [PATCH 10/11] fix: add translation for alt --- .../src/app/dashboard/sidebar/sidebar.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html index 8491a2091f..fc99769cb1 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html @@ -35,7 +35,7 @@ > Log out From 08547bb4816f10d3c17532e35aafa069678f2087 Mon Sep 17 00:00:00 2001 From: cmoinier Date: Mon, 25 Nov 2024 16:35:33 +0100 Subject: [PATCH 11/11] feat: replace window.location with window.origin --- .../src/app/dashboard/sidebar/sidebar.component.spec.ts | 4 ++-- .../src/app/dashboard/sidebar/sidebar.component.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts index 15419cda92..8743381d52 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.spec.ts @@ -53,14 +53,14 @@ describe('SidebarComponent', () => { ok: true, } as Response) - const originalUrl = window.location.href + const originalUrl = window.origin await component.logOut() expect(window.fetch).toHaveBeenCalledWith(service.logoutUrl, { method: 'GET', }) - expect(window.location.href).toBe(originalUrl) + expect(window.location.href.slice(0, -1)).toBe(originalUrl) }) }) }) diff --git a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts index 53fc909f64..8b88be4411 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.ts @@ -47,7 +47,7 @@ export class SidebarComponent implements OnInit { } logOut() { - const current_url = window.location.toString() + const current_url = window.origin.toString() fetch(this.authService.logoutUrl, { method: 'GET', })