diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts index 47132f26e7..6f206e8489 100644 --- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts @@ -342,6 +342,18 @@ describe('dashboard (authenticated)', () => { }) }) }) + describe('Account settings access', () => { + it('should navigate to the account settings page', () => { + cy.visit('/catalog/search') + cy.get('md-editor-sidebar') + .find('gn-ui-button') + .first() + .find('a') + .invoke('removeAttr', 'target') + .click() + cy.url().should('include', '/admin.console') + }) + }) }) describe('Logging in and out', () => { diff --git a/apps/metadata-editor/src/app/app.module.ts b/apps/metadata-editor/src/app/app.module.ts index c2a3784725..ce7a03c927 100644 --- a/apps/metadata-editor/src/app/app.module.ts +++ b/apps/metadata-editor/src/app/app.module.ts @@ -27,6 +27,7 @@ import { EditorRouterService } from './router.service' import { LOGIN_URL, LOGOUT_URL, + SETTINGS_URL, provideGn4, provideRepositoryUrl, } from '@geonetwork-ui/api/repository' @@ -75,6 +76,10 @@ import { FeatureEditorModule } from '@geonetwork-ui/feature/editor' provide: LOGOUT_URL, useFactory: () => getGlobalConfig().LOGOUT_URL, }, + { + provide: SETTINGS_URL, + useFactory: () => getGlobalConfig().SETTINGS_URL, + }, ], bootstrap: [AppComponent], }) 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 fc99769cb1..d20f4982ee 100644 --- a/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html +++ b/apps/metadata-editor/src/app/dashboard/sidebar/sidebar.component.html @@ -20,13 +20,15 @@ > - + + + + get settingsUrl() { + return this.authService.settingsUrl + } + constructor( public platformService: PlatformServiceInterface, private avatarService: AvatarServiceInterface, diff --git a/conf/default.toml b/conf/default.toml index bae70b32dc..2586bd0866 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -24,6 +24,7 @@ proxy_path = "" # Example to use the georchestra login page: # login_url = "/cas/login?service=${current_url}" # logout_url = "/geonetwork/signout" +# settings_url = "/geonetwork/srv/\${lang3}/admin.console#/organization/users?userOrGroup=" # 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.spec.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts index dabc434e34..cc3fc4d381 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 @@ -91,4 +91,14 @@ describe('AuthService', () => { expect(service.logoutUrl).toEqual('/geonetwork/signout') }) }) + describe('Settings', () => { + beforeEach(() => { + service = TestBed.inject(AuthService) + }) + it('should return the logout url', () => { + expect(service.settingsUrl).toEqual( + '/geonetwork/srv/fre/admin.console#/organization/users?userOrGroup=' + ) + }) + }) }) 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 667e817aa3..da6d7fae3b 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.ts @@ -8,12 +8,17 @@ export const LOGIN_URL = new InjectionToken('loginUrl') export const DEFAULT_GN4_LOGOUT_URL = `/geonetwork/signout` export const LOGOUT_URL = new InjectionToken('logoutUrl') +export const DEFAULT_GN4_SETTINGS_URL = `/geonetwork/srv/\${lang3}/admin.console#/organization/users?userOrGroup=` +export const SETTINGS_URL = new InjectionToken('settingsUrl') + @Injectable({ providedIn: 'root', }) export class AuthService { baseLoginUrl = this.baseLoginUrlToken || DEFAULT_GN4_LOGIN_URL baseLogoutUrl = this.baseLogoutUrlToken || DEFAULT_GN4_LOGOUT_URL + baseSettingsUrl = this.baseSettingsUrlToken || DEFAULT_GN4_SETTINGS_URL + get loginUrl() { let baseUrl = this.baseLoginUrl const locationHasQueryParams = !!window.location.search @@ -34,9 +39,17 @@ export class AuthService { return this.baseLogoutUrl } + get settingsUrl() { + return this.baseSettingsUrl.replace( + '${lang3}', + LANG_2_TO_3_MAPPER[this.translateService.currentLang] + ) + } + constructor( @Optional() @Inject(LOGIN_URL) private baseLoginUrlToken: string, @Optional() @Inject(LOGOUT_URL) private baseLogoutUrlToken: string, + @Optional() @Inject(SETTINGS_URL) private baseSettingsUrlToken: string, private translateService: TranslateService ) {} } diff --git a/libs/ui/elements/src/lib/user-preview/user-preview.component.html b/libs/ui/elements/src/lib/user-preview/user-preview.component.html index 361fa66a73..2aa537d283 100644 --- a/libs/ui/elements/src/lib/user-preview/user-preview.component.html +++ b/libs/ui/elements/src/lib/user-preview/user-preview.component.html @@ -1,8 +1,5 @@
-
+