fix(auth): Fix auth flow for the client app
This commit is contained in:
committed by
mrugesh mohapatra
parent
a656cbf98a
commit
c08bb95ea8
@@ -11,7 +11,12 @@ import { ofType } from 'redux-observable';
|
||||
import store from 'store';
|
||||
import uuid from 'uuid/v4';
|
||||
|
||||
import { types, onlineStatusChange, isOnlineSelector } from './';
|
||||
import {
|
||||
types,
|
||||
onlineStatusChange,
|
||||
isOnlineSelector,
|
||||
isSignedInSelector
|
||||
} from './';
|
||||
import postUpdate$ from '../templates/Challenges/utils/postUpdate$';
|
||||
import { isGoodXHRStatus } from '../templates/Challenges/utils';
|
||||
|
||||
@@ -36,6 +41,7 @@ function failedUpdateEpic(action$, state$) {
|
||||
|
||||
const flushUpdates = action$.pipe(
|
||||
ofType(types.fetchUserComplete, types.updateComplete),
|
||||
filter(() => isSignedInSelector(state$.value)),
|
||||
filter(() => store.get(key)),
|
||||
filter(() => isOnlineSelector(state$.value)),
|
||||
tap(() => {
|
||||
|
@@ -2,8 +2,13 @@ import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
|
||||
import { fetchUserComplete, fetchUserError } from './';
|
||||
import { getSessionUser } from '../utils/ajax';
|
||||
import { jwt } from './cookieValues';
|
||||
|
||||
function* fetchSessionUser() {
|
||||
if (!jwt) {
|
||||
yield put(fetchUserComplete({ user: {}, username: '' }));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const {
|
||||
data: { user = {}, result = '' }
|
||||
|
@@ -47,6 +47,7 @@ export const types = createTypes(
|
||||
[
|
||||
'appMount',
|
||||
'closeDonationModal',
|
||||
'hardGoTo',
|
||||
'openDonationModal',
|
||||
'onlineStatusChange',
|
||||
'updateComplete',
|
||||
@@ -81,6 +82,11 @@ export const openDonationModal = createAction(types.openDonationModal);
|
||||
|
||||
export const onlineStatusChange = createAction(types.onlineStatusChange);
|
||||
|
||||
// `hardGoTo` is used to hit the API server directly
|
||||
// without going through /internal
|
||||
// used for things like /signin and /signout
|
||||
export const hardGoTo = createAction(types.hardGoTo);
|
||||
|
||||
export const updateComplete = createAction(types.updateComplete);
|
||||
export const updateFailed = createAction(types.updateFailed);
|
||||
|
||||
|
Reference in New Issue
Block a user