orc-shared 1.6.0-dev.8 → 1.6.0-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/reducers/request.js
CHANGED
|
@@ -46,7 +46,8 @@ var requestReducer = function requestReducer(state, action) {
|
|
|
46
46
|
}
|
|
47
47
|
if (action.type.endsWith("_FAILURE")) {
|
|
48
48
|
var _requestName2 = action.type.replace(/_FAILURE$/, "");
|
|
49
|
-
|
|
49
|
+
var status = (0, _utils.safeGet)(action, "payload", "status");
|
|
50
|
+
if (status === 403 || status === 401) {
|
|
50
51
|
return state.deleteIn(["actives", _requestName2]).set("logout", true);
|
|
51
52
|
} else {
|
|
52
53
|
return state.deleteIn(["actives", _requestName2]).set("error", _immutable.default.fromJS(action));
|
package/package.json
CHANGED
package/src/reducers/request.js
CHANGED
|
@@ -24,7 +24,8 @@ const requestReducer = (state = initialState, action) => {
|
|
|
24
24
|
}
|
|
25
25
|
if (action.type.endsWith("_FAILURE")) {
|
|
26
26
|
const requestName = action.type.replace(/_FAILURE$/, "");
|
|
27
|
-
|
|
27
|
+
const status = safeGet(action, "payload", "status");
|
|
28
|
+
if (status === 403 || status === 401) {
|
|
28
29
|
return state.deleteIn(["actives", requestName]).set("logout", true);
|
|
29
30
|
} else {
|
|
30
31
|
return state.deleteIn(["actives", requestName]).set("error", Immutable.fromJS(action));
|
|
@@ -125,4 +125,27 @@ describe("Request reducer", () => {
|
|
|
125
125
|
}),
|
|
126
126
|
);
|
|
127
127
|
});
|
|
128
|
+
|
|
129
|
+
it("clears activity flag and sets login flag when a request fails with status 401", () => {
|
|
130
|
+
const oldState = Immutable.fromJS({
|
|
131
|
+
actives: {
|
|
132
|
+
SOME_FLAG: true,
|
|
133
|
+
TEST_THIS: true,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
const action = {
|
|
137
|
+
type: "TEST_THIS_FAILURE",
|
|
138
|
+
payload: { status: 401, message: "UnauthorizedAccessException" },
|
|
139
|
+
};
|
|
140
|
+
const newState = reducer(oldState, action);
|
|
141
|
+
expect(newState, "not to be", oldState).and(
|
|
142
|
+
"to equal",
|
|
143
|
+
Immutable.fromJS({
|
|
144
|
+
actives: {
|
|
145
|
+
SOME_FLAG: true,
|
|
146
|
+
},
|
|
147
|
+
[LOGOUT]: true,
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
});
|
|
128
151
|
});
|