mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 13:33:03 +00:00
Improved redirect url management
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { ServerResponseService } from '../shared/services/server-response.service';
|
||||
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
|
||||
import { AuthService } from '../core/auth/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-pagenotfound',
|
||||
@@ -7,8 +8,13 @@ import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||
templateUrl: './pagenotfound.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.Default
|
||||
})
|
||||
export class PageNotFoundComponent {
|
||||
constructor(responseService: ServerResponseService) {
|
||||
responseService.setNotFound();
|
||||
export class PageNotFoundComponent implements OnInit {
|
||||
constructor(private authservice: AuthService, private responseService: ServerResponseService) {
|
||||
this.responseService.setNotFound();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.authservice.clearRedirectUrl();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { of as observableOf, Observable , Subscription } from 'rxjs';
|
||||
import { Observable, of as observableOf, Subscription } from 'rxjs';
|
||||
|
||||
import { map, filter } from 'rxjs/operators';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { RouterReducerState } from '@ngrx/router-store';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
@@ -9,13 +9,9 @@ import { fadeInOut, fadeOut } from '../animations/fade';
|
||||
import { HostWindowService } from '../host-window.service';
|
||||
import { AppState, routerStateSelector } from '../../app.reducer';
|
||||
import { isNotUndefined } from '../empty.util';
|
||||
import {
|
||||
getAuthenticatedUser,
|
||||
isAuthenticated,
|
||||
isAuthenticationLoading
|
||||
} from '../../core/auth/selectors';
|
||||
import { getAuthenticatedUser, isAuthenticated, isAuthenticationLoading } from '../../core/auth/selectors';
|
||||
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||
import { AuthService, LOGIN_ROUTE, LOGOUT_ROUTE } from '../../core/auth/auth.service';
|
||||
import { LOGIN_ROUTE, LOGOUT_ROUTE } from '../../core/auth/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-auth-nav-menu',
|
||||
@@ -45,8 +41,7 @@ export class AuthNavMenuComponent implements OnInit {
|
||||
public sub: Subscription;
|
||||
|
||||
constructor(private store: Store<AppState>,
|
||||
private windowService: HostWindowService,
|
||||
private authService: AuthService
|
||||
private windowService: HostWindowService
|
||||
) {
|
||||
this.isXsOrSm$ = this.windowService.isXsOrSm();
|
||||
}
|
||||
@@ -63,14 +58,9 @@ export class AuthNavMenuComponent implements OnInit {
|
||||
this.showAuth = this.store.pipe(
|
||||
select(routerStateSelector),
|
||||
filter((router: RouterReducerState) => isNotUndefined(router) && isNotUndefined(router.state)),
|
||||
map((router: RouterReducerState) => {
|
||||
const url = router.state.url;
|
||||
const show = !router.state.url.startsWith(LOGIN_ROUTE) && !router.state.url.startsWith(LOGOUT_ROUTE);
|
||||
if (show) {
|
||||
this.authService.setRedirectUrl(url);
|
||||
}
|
||||
return show;
|
||||
})
|
||||
map((router: RouterReducerState) => (!router.state.url.startsWith(LOGIN_ROUTE)
|
||||
&& !router.state.url.startsWith(LOGOUT_ROUTE))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user