kikocis/dataspace-portal public
Changesets · Branches · Tags · Compare
| Changeset | 0851d8a418d861427d11accf2dc65abfd9ce75a111bf5aba1f55e5a7036d267c |
|---|---|
| Author | Ilia Orlov <66363651+illfixit@users.noreply.github.com> · 2024-11-28 17:48 +01:00 |
| Committer | GitHub <noreply@github.com> · 2024-11-28 17:48 +01:00 |
| Parents | 23938f4a7f5e |
6 files changed
modified CHANGELOG.md +1 −0
| @@ -26,6 +26,7 @@ | ||
| 26 | 26 | - Added live update when deactivating/reactivating users ([#287](https://github.com/sovity/authority-portal/issues/287)) |
| 27 | 27 | - Fixed Website title not updating in some scenarios [#237](https://github.com/sovity/authority-portal/issues/237) |
| 28 | 28 | - Fixed security vulnerabilities |
| 29 | +- Fixed the user not being redirected to the correct URL after login ([#324](https://github.com/sovity/authority-portal/issues/324)) | |
| 29 | 30 | |
| 30 | 31 | ### Known issues |
| 31 | 32 |
modified authority-portal-frontend/src/app/app-routing.module.ts +11 −12
| @@ -74,17 +74,6 @@ | ||
| 74 | 74 | }, |
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | -export const FEATURE_HOME_ROUTE: Routes = [ | |
| 78 | - { | |
| 79 | - path: 'home', | |
| 80 | - component: HomePageComponent, | |
| 81 | - data: { | |
| 82 | - requiresRole: ['USER'] satisfies UserRoleDto[], | |
| 83 | - }, | |
| 84 | - canActivate: [requiresRole], | |
| 85 | - }, | |
| 86 | -]; | |
| 87 | - | |
| 88 | 77 | const REDIRECT_TO_HOME: string[] = [ |
| 89 | 78 | '', |
| 90 | 79 | 'registration/pending', |
| @@ -94,7 +83,6 @@ | ||
| 94 | 83 | |
| 95 | 84 | const getProperRedirectUrl = (fallbackUrl: string) => { |
| 96 | 85 | const url = localStorage.getItem('originalUrl') || fallbackUrl; |
| 97 | - localStorage.removeItem('originalUrl'); | |
| 98 | 86 | return url; |
| 99 | 87 | }; |
| 100 | 88 | |
| @@ -110,6 +98,17 @@ | ||
| 110 | 98 | pathMatch: 'full', |
| 111 | 99 | })); |
| 112 | 100 | |
| 101 | +export const FEATURE_HOME_ROUTE: Routes = [ | |
| 102 | + { | |
| 103 | + path: 'home', | |
| 104 | + component: HomePageComponent, | |
| 105 | + data: { | |
| 106 | + requiresRole: ['USER'] satisfies UserRoleDto[], | |
| 107 | + }, | |
| 108 | + canActivate: [requiresRole], | |
| 109 | + }, | |
| 110 | +]; | |
| 111 | + | |
| 113 | 112 | export const FEATURE_DASHBOARD_ROUTE: Routes = [ |
| 114 | 113 | { |
| 115 | 114 | path: 'dashboard', |
modified authority-portal-frontend/src/app/core/global-state/global-state-impl.ts +6 −0
| @@ -34,6 +34,7 @@ | ||
| 34 | 34 | } from './global-state-actions'; |
| 35 | 35 | import {AuthorityPortalPageSet} from './routes/authority-portal-page-set'; |
| 36 | 36 | import {RouteConfigService} from './routes/route-config-service'; |
| 37 | +import {UrlBeforeLoginService} from './routes/url-before-login.service'; | |
| 37 | 38 | |
| 38 | 39 | @State<GlobalState>({ |
| 39 | 40 | name: 'GlobalState', |
| @@ -46,6 +47,7 @@ | ||
| 46 | 47 | private ngZone: NgZone, |
| 47 | 48 | private apiService: ApiService, |
| 48 | 49 | private routeConfigService: RouteConfigService, |
| 50 | + private urlBeforeLoginService: UrlBeforeLoginService, | |
| 49 | 51 | ) {} |
| 50 | 52 | |
| 51 | 53 | ngxsOnInit(ctx: StateContext<any>): void { |
| @@ -123,6 +125,10 @@ | ||
| 123 | 125 | let roles = new Set(userInfo.map((it) => it.roles).orElse([])); |
| 124 | 126 | roles = isEqualSets(state.roles, roles) ? state.roles : roles; |
| 125 | 127 | |
| 128 | + if (!roles.has('UNAUTHENTICATED')) { | |
| 129 | + this.urlBeforeLoginService.clearOriginalUrl(); | |
| 130 | + } | |
| 131 | + | |
| 126 | 132 | return {userInfo, pageSet, roles}; |
| 127 | 133 | }); |
| 128 | 134 | } |
modified authority-portal-frontend/src/app/core/global-state/routes/route-config-service.ts +21 −13
| @@ -83,21 +83,29 @@ | ||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Change routes |
| 86 | - const routes = this.mapping[nextPageSet]; | |
| 86 | + const routes = [...this.mapping[nextPageSet]]; | |
| 87 | 87 | |
| 88 | 88 | if (nextPageSet === 'AUTHORITY_PORTAL') { |
| 89 | - const apRouteChildren = routes.find((r) => r.path === '')?.children; | |
| 90 | - | |
| 91 | - // Add home route depending on feature set | |
| 92 | - if (this.activeFeatureSet.isHomePageEnabled()) { | |
| 93 | - apRouteChildren?.push(...HOME_REDIRECTS, ...FEATURE_HOME_ROUTE); | |
| 94 | - } else { | |
| 95 | - apRouteChildren?.push(...CATALOG_REDIRECTS); | |
| 96 | - } | |
| 97 | - | |
| 98 | - // Add additional routes depending on feature set & configuration | |
| 99 | - if (this.activeFeatureSet.isDashboardEnabled()) { | |
| 100 | - apRouteChildren?.push(...FEATURE_DASHBOARD_ROUTE); | |
| 89 | + const rootRouteIndex = routes.findIndex((r) => r.path === ''); | |
| 90 | + | |
| 91 | + if (rootRouteIndex !== -1) { | |
| 92 | + const rootRoute = routes[rootRouteIndex]; | |
| 93 | + const existingChildren = rootRoute.children || []; | |
| 94 | + | |
| 95 | + // Add home route depending on feature set | |
| 96 | + const newChildren = this.activeFeatureSet.isHomePageEnabled() | |
| 97 | + ? [...existingChildren, ...HOME_REDIRECTS, ...FEATURE_HOME_ROUTE] | |
| 98 | + : [...existingChildren, ...CATALOG_REDIRECTS]; | |
| 99 | + | |
| 100 | + // Add additional routes depending on feature set & configuration | |
| 101 | + if (this.activeFeatureSet.isDashboardEnabled()) { | |
| 102 | + newChildren.push(...FEATURE_DASHBOARD_ROUTE); | |
| 103 | + } | |
| 104 | + | |
| 105 | + routes[rootRouteIndex] = { | |
| 106 | + ...rootRoute, | |
| 107 | + children: newChildren, | |
| 108 | + }; | |
| 101 | 109 | } |
| 102 | 110 | } |
| 103 | 111 |
modified authority-portal-frontend/src/app/core/global-state/routes/url-before-login.service.ts +3 −2
| @@ -28,14 +28,15 @@ | ||
| 28 | 28 | }); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public reset(): void { | |
| 31 | + public clearOriginalUrl(): void { | |
| 32 | 32 | this.originalUrl = ''; |
| 33 | + localStorage.removeItem('originalUrl'); | |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | 36 | public goToOriginalUrl(): void { |
| 36 | 37 | if (this.originalUrl) { |
| 37 | 38 | this.router.navigateByUrl(this.originalUrl); |
| 38 | - this.reset(); | |
| 39 | + this.clearOriginalUrl(); | |
| 39 | 40 | } |
| 40 | 41 | } |
| 41 | 42 | } |
modified authority-portal-frontend/src/app/pages/home/home/home.component.ts +3 −1
| @@ -11,7 +11,7 @@ | ||
| 11 | 11 | * sovity GmbH - initial implementation |
| 12 | 12 | */ |
| 13 | 13 | import {Component, HostBinding, Inject} from '@angular/core'; |
| 14 | -import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser'; | |
| 14 | +import {DomSanitizer, SafeResourceUrl, Title} from '@angular/platform-browser'; | |
| 15 | 15 | import {APP_CONFIG, AppConfig} from 'src/app/core/services/config/app-config'; |
| 16 | 16 | |
| 17 | 17 | @Component({ |
| @@ -31,7 +31,9 @@ | ||
| 31 | 31 | constructor( |
| 32 | 32 | @Inject(APP_CONFIG) public appConfig: AppConfig, |
| 33 | 33 | private sanitizer: DomSanitizer, |
| 34 | + private titleService: Title, | |
| 34 | 35 | ) { |
| 36 | + this.titleService.setTitle('Home'); | |
| 35 | 37 | if (this.appConfig.iframeUrl) { |
| 36 | 38 | this.iframeUrl = this.sanitizer.bypassSecurityTrustResourceUrl( |
| 37 | 39 | this.appConfig.iframeUrl, |