nicolium: hack for fixing broken login, will refactor and clean this up soon
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -288,13 +288,15 @@ interface SwitchAccountAction {
|
||||
account: Account;
|
||||
}
|
||||
|
||||
const switchAccount = (accountId: string) => (dispatch: AppDispatch) => {
|
||||
const switchAccount = (accountId: string) => (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const account = selectAccount(accountId);
|
||||
if (!account) return;
|
||||
|
||||
// Clear all stored cache from React Query
|
||||
queryClient.invalidateQueries();
|
||||
queryClient.clear();
|
||||
if (typeof getState().me === 'string' && getState().me !== account.id) {
|
||||
// Clear all stored cache from React Query
|
||||
queryClient.invalidateQueries();
|
||||
queryClient.clear();
|
||||
}
|
||||
|
||||
return dispatch<SwitchAccountAction>({ type: SWITCH_ACCOUNT, account });
|
||||
};
|
||||
|
||||
@ -48,9 +48,8 @@ const SignUpPanel = () => {
|
||||
return account;
|
||||
})
|
||||
.then((account: { id: string }) => {
|
||||
if (typeof me === 'string') {
|
||||
dispatch(switchAccount(account.id));
|
||||
} else {
|
||||
dispatch(switchAccount(account.id));
|
||||
if (typeof me !== 'string') {
|
||||
setShouldRedirect(true);
|
||||
}
|
||||
})
|
||||
|
||||
@ -47,9 +47,8 @@ const LoginPage = () => {
|
||||
})
|
||||
.then((account: { id: string }) => {
|
||||
closeModal();
|
||||
if (typeof me === 'string') {
|
||||
dispatch(switchAccount(account.id));
|
||||
} else {
|
||||
dispatch(switchAccount(account.id));
|
||||
if (typeof me !== 'string') {
|
||||
setShouldRedirect(true);
|
||||
}
|
||||
})
|
||||
|
||||
@ -3,6 +3,7 @@ import {
|
||||
AUTH_ACCOUNT_REMEMBER_SUCCESS,
|
||||
VERIFY_CREDENTIALS_SUCCESS,
|
||||
type AuthAction,
|
||||
SWITCH_ACCOUNT,
|
||||
} from '@/actions/auth';
|
||||
import {
|
||||
ME_FETCH_SUCCESS,
|
||||
@ -38,6 +39,8 @@ const me = (state: Me = initialState, action: AuthAction | MeAction): Me => {
|
||||
return false;
|
||||
case ME_FETCH_FAIL:
|
||||
return handleForbidden(state, action.error as any);
|
||||
case SWITCH_ACCOUNT:
|
||||
return action.account.id;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user