diff --git a/src/app/core/auth/auth.effects.ts b/src/app/core/auth/auth.effects.ts index dcedbe0aec..3606434420 100644 --- a/src/app/core/auth/auth.effects.ts +++ b/src/app/core/auth/auth.effects.ts @@ -133,10 +133,16 @@ export class AuthEffects { @Effect({dispatch: false}) public redirectToLogin: Observable = this.actions$ - .ofType(AuthActionTypes.REDIRECT_TOKEN_EXPIRED, AuthActionTypes.REDIRECT_AUTHENTICATION_REQUIRED) + .ofType(AuthActionTypes.REDIRECT_AUTHENTICATION_REQUIRED) .do(() => this.authService.removeToken()) .do(() => this.authService.redirectToLogin()); + @Effect({dispatch: false}) + public redirectToLogin: Observable = this.actions$ + .ofType(AuthActionTypes.REDIRECT_TOKEN_EXPIRED) + .do(() => this.authService.removeToken()) + .do(() => this.authService.redirectToLoginWhenTokenExpired()); + /** * @constructor * @param {Actions} actions$ diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index cb827b1101..557dde73c0 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -276,6 +276,13 @@ export class AuthService { * Redirect to the login route */ public redirectToLogin() { + this.router.navigate(LOGIN_ROUTE); + } + + /** + * Redirect to the login route when token has expired + */ + public redirectToLoginWhenTokenExpired() { // Hard redirect to login page, so that all state is definitely lost this._window.nativeWindow.location.href = LOGIN_ROUTE + '?expired=true'; }