Skip to content

Commit

Permalink
fix(auth): force reload to / on any logout result (#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Apr 15, 2024
1 parent a9c3d73 commit c93e6b4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/app/Shared/Services/Login.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { Observable, ObservableInput, of, ReplaySubject } from 'rxjs';
import { fromFetch } from 'rxjs/fetch';
import { catchError, concatMap, debounceTime, distinctUntilChanged, map, tap } from 'rxjs/operators';
import { catchError, concatMap, debounceTime, distinctUntilChanged, finalize, map, tap } from 'rxjs/operators';
import { SessionState } from './service.types';
import type { SettingsService } from './Settings.service';

Expand Down Expand Up @@ -55,16 +55,14 @@ export class LoginService {
concatMap((response) => {
return of(response).pipe(
map((response) => response.ok),
tap(() => {
this.resetSessionState();
this.navigateToLoginPage();
}),
tap(() => this.resetSessionState()),
);
}),
catchError((e: Error): ObservableInput<boolean> => {
window.console.error(JSON.stringify(e, Object.getOwnPropertyNames(e)));
return of(false);
}),
finalize(() => this.navigateToLoginPage()),
);
}

Expand All @@ -78,7 +76,6 @@ export class LoginService {
}

private navigateToLoginPage(): void {
const url = new URL(window.location.href.split('#')[0]);
window.location.href = url.pathname.match(/\/settings/i) ? '/' : url.pathname;
window.location.href = '/';
}
}

0 comments on commit c93e6b4

Please sign in to comment.