diff --git a/src/app/pagenotfound/pagenotfound.component.ts b/src/app/pagenotfound/pagenotfound.component.ts index e7923b3466..a3a55c26bf 100644 --- a/src/app/pagenotfound/pagenotfound.component.ts +++ b/src/app/pagenotfound/pagenotfound.component.ts @@ -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(); + } + } diff --git a/src/app/shared/auth-nav-menu/auth-nav-menu.component.ts b/src/app/shared/auth-nav-menu/auth-nav-menu.component.ts index 4361163538..1b39ad15d9 100644 --- a/src/app/shared/auth-nav-menu/auth-nav-menu.component.ts +++ b/src/app/shared/auth-nav-menu/auth-nav-menu.component.ts @@ -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, - 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)) + ) ); } }