Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): force reload to / on any logout result #1237

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = '/';
}
}
Loading