mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Added redirect after logout
This commit is contained in:
@@ -129,7 +129,7 @@ export class AuthEffects {
|
|||||||
public logOutSuccess: Observable<Action> = this.actions$
|
public logOutSuccess: Observable<Action> = this.actions$
|
||||||
.ofType(AuthActionTypes.LOG_OUT_SUCCESS)
|
.ofType(AuthActionTypes.LOG_OUT_SUCCESS)
|
||||||
.do(() => this.authService.removeToken())
|
.do(() => this.authService.removeToken())
|
||||||
.do(() => this.authService.refreshPage());
|
.do(() => this.authService.refreshAfterLogout());
|
||||||
|
|
||||||
@Effect({dispatch: false})
|
@Effect({dispatch: false})
|
||||||
public redirectToLogin: Observable<Action> = this.actions$
|
public redirectToLogin: Observable<Action> = this.actions$
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { NavigationExtras, PRIMARY_OUTLET, Router, UrlSegmentGroup, UrlTree } from '@angular/router';
|
import { NavigationExtras, PRIMARY_OUTLET, Router, UrlSegmentGroup, UrlTree } from '@angular/router';
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
@@ -18,6 +18,7 @@ import { Store } from '@ngrx/store';
|
|||||||
import { ResetAuthenticationMessagesAction, SetRedirectUrlAction } from './auth.actions';
|
import { ResetAuthenticationMessagesAction, SetRedirectUrlAction } from './auth.actions';
|
||||||
import { RouterReducerState } from '@ngrx/router-store';
|
import { RouterReducerState } from '@ngrx/router-store';
|
||||||
import { CookieAttributes } from 'js-cookie';
|
import { CookieAttributes } from 'js-cookie';
|
||||||
|
import { NativeWindowRef, NativeWindowService } from '../../shared/services/window.service';
|
||||||
|
|
||||||
export const LOGIN_ROUTE = '/login';
|
export const LOGIN_ROUTE = '/login';
|
||||||
|
|
||||||
@@ -33,7 +34,8 @@ export class AuthService {
|
|||||||
*/
|
*/
|
||||||
private _authenticated: boolean;
|
private _authenticated: boolean;
|
||||||
|
|
||||||
constructor(private authRequestService: AuthRequestService,
|
constructor(@Inject(NativeWindowService) private _window: NativeWindowRef,
|
||||||
|
private authRequestService: AuthRequestService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private storage: CookieService,
|
private storage: CookieService,
|
||||||
private store: Store<AppState>) {
|
private store: Store<AppState>) {
|
||||||
@@ -290,14 +292,9 @@ export class AuthService {
|
|||||||
/**
|
/**
|
||||||
* Refresh route navigated
|
* Refresh route navigated
|
||||||
*/
|
*/
|
||||||
public refreshPage() {
|
public refreshAfterLogout() {
|
||||||
this.store.select(routerStateSelector)
|
// Hard redirect to home page, so that all state is definitely lost
|
||||||
.take(1)
|
this._window.nativeWindow.location.href = '/home';
|
||||||
.subscribe((router) => {
|
|
||||||
// TODO Check a way to hard refresh the same route
|
|
||||||
// this.router.navigate([router.state.url], { replaceUrl: true });
|
|
||||||
this.router.navigate(['/']);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user