diff --git a/booklore-ui/src/app/core/security/auth-interceptor.service.ts b/booklore-ui/src/app/core/security/auth-interceptor.service.ts index df6f71905..d1e237d89 100644 --- a/booklore-ui/src/app/core/security/auth-interceptor.service.ts +++ b/booklore-ui/src/app/core/security/auth-interceptor.service.ts @@ -73,7 +73,6 @@ function handle401Error(authService: AuthService, request: HttpRequest, nex } function forceLogout(authService: AuthService, router: Router, message?: string): void { - authService.logout(); - router.navigate(['/login']); if (message) console.warn(message); + authService.logout(); } diff --git a/booklore-ui/src/app/shared/components/change-password/change-password.component.ts b/booklore-ui/src/app/shared/components/change-password/change-password.component.ts index bacfadd93..6b8d8faa6 100644 --- a/booklore-ui/src/app/shared/components/change-password/change-password.component.ts +++ b/booklore-ui/src/app/shared/components/change-password/change-password.component.ts @@ -73,6 +73,5 @@ export class ChangePasswordComponent { logout() { this.authService.logout(); - window.location.href = '/login'; } } diff --git a/booklore-ui/src/app/shared/service/auth.service.ts b/booklore-ui/src/app/shared/service/auth.service.ts index 68315d1d2..826a53ea4 100644 --- a/booklore-ui/src/app/shared/service/auth.service.ts +++ b/booklore-ui/src/app/shared/service/auth.service.ts @@ -94,7 +94,9 @@ export class AuthService { this.oAuthStorage.removeItem("id_token"); this.tokenSubject.next(null); this.getRxStompService().deactivate(); - this.router.navigate(['/login']); + + // Force reload so user's data is not cached for next user that logs in + window.location.href = '/login'; } getRxStompService(): RxStompService {