Skip to content

Commit

Permalink
Removed auth status check experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
pkirilin committed Jan 20, 2024
1 parent 21be80e commit 9365b84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 48 deletions.
36 changes: 0 additions & 36 deletions src/frontend/src/authStatusCheck.ts

This file was deleted.

18 changes: 12 additions & 6 deletions src/frontend/src/features/auth/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ interface UseAuthHookResult {
export default function useAuth(): UseAuthHookResult {
const user = useAppSelector(state => state.auth.user);
const dispatch = useAppDispatch();
const [getAuthStatus, getAuthStatusRequest] = authApi.useLazyGetStatusQuery();

const { refetch, isFetching } = authApi.useGetStatusQuery(
{},
{
skip: !!user,
},
);

const signIn = useCallback(() => {
dispatch(actions.signIn());
Expand Down Expand Up @@ -54,16 +60,16 @@ export default function useAuth(): UseAuthHookResult {
}, [signOut]);

const completeLogin = useCallback(() => {
void getAuthStatus({});
}, [getAuthStatus]);
void refetch();
}, [refetch]);

const completeLogout = useCallback(() => {
void getAuthStatus({});
}, [getAuthStatus]);
void refetch();
}, [refetch]);

return {
user,
isLoggingIn: getAuthStatusRequest.isFetching,
isLoggingIn: isFetching,
login,
logout,
completeLogin,
Expand Down
7 changes: 1 addition & 6 deletions src/frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { initBrowserMockApi } from 'tests/mockApi';
import { createRoot } from 'react-dom/client';
import App from './App';
import AppProvider from './AppProvider';
import { initAuthUserState } from './authStatusCheck';
import { FAKE_AUTH_ENABLED, GOOGLE_ANALYTICS_ENABLED, MSW_ENABLED } from './config';
import { GOOGLE_ANALYTICS_ENABLED, MSW_ENABLED } from './config';
import { initGoogleAnalytics } from './googleAnalytics';
import store from './store';

Expand All @@ -17,10 +16,6 @@ void (async () => {
initGoogleAnalytics();
}

if (!FAKE_AUTH_ENABLED) {
await initAuthUserState(store);
}

const container = document.getElementById('root') as HTMLElement;
const root = createRoot(container);

Expand Down

0 comments on commit 9365b84

Please sign in to comment.