Skip to content

Commit

Permalink
adds withCredentials to true
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Jul 13, 2019
1 parent 4953611 commit 4b3d376
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function interceptorFunctionRequestFulfilled(config) {
}
const preRequestIdToken = getIDFromCookie();
const antiCsrfToken = AntiCsrfToken.getToken(preRequestIdToken);
config = Object.assign({}, config, { withCredentials: true });
let configWithAntiCsrf = config;
if (antiCsrfToken !== undefined) {
configWithAntiCsrf = Object.assign({}, configWithAntiCsrf, {
Expand Down Expand Up @@ -98,6 +99,7 @@ AuthHttpRequest.doRequest = (httpCall, config, url, prevResponse, prevError, via
// to avoid race conditions
const preRequestIdToken = getIDFromCookie();
const antiCsrfToken = AntiCsrfToken.getToken(preRequestIdToken);
config = Object.assign({}, config, { withCredentials: true });
let configWithAntiCsrf = config;
if (antiCsrfToken !== undefined) {
configWithAntiCsrf = Object.assign({}, configWithAntiCsrf, {
Expand Down
8 changes: 8 additions & 0 deletions axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ async function interceptorFunctionRequestFulfilled(config: AxiosRequestConfig) {
}
const preRequestIdToken = getIDFromCookie();
const antiCsrfToken = AntiCsrfToken.getToken(preRequestIdToken);
config = {
...config,
withCredentials: true
};
let configWithAntiCsrf: AxiosRequestConfig = config;
if (antiCsrfToken !== undefined) {
configWithAntiCsrf = {
Expand Down Expand Up @@ -83,6 +87,10 @@ export default class AuthHttpRequest {
// to avoid race conditions
const preRequestIdToken = getIDFromCookie();
const antiCsrfToken = AntiCsrfToken.getToken(preRequestIdToken);
config = {
...config,
withCredentials: true
};
let configWithAntiCsrf: AxiosRequestConfig = config;
if (antiCsrfToken !== undefined) {
configWithAntiCsrf = {
Expand Down
3 changes: 2 additions & 1 deletion handleSessionExp.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export function onUnauthorisedResponse(refreshTokenUrl, preRequestIdToken) {
return { result: "RETRY" };
}
let response = yield AuthHttpRequest.originalFetch(refreshTokenUrl, {
method: "post"
method: "post",
credentials: "include"
});
if (response.status !== 200) {
throw response;
Expand Down
3 changes: 2 additions & 1 deletion handleSessionExp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export async function onUnauthorisedResponse(
return { result: "RETRY" };
}
let response = await AuthHttpRequest.originalFetch(refreshTokenUrl, {
method: "post"
method: "post",
credentials: "include"
});
if (response.status !== 200) {
throw response;
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ AuthHttpRequest.doRequest = (httpCall, config, url) =>
// to avoid race conditions
const preRequestIdToken = getIDFromCookie();
const antiCsrfToken = AntiCsrfToken.getToken(preRequestIdToken);
config = Object.assign({}, config, { credentials: "include" });
let configWithAntiCsrf = config;
if (antiCsrfToken !== undefined) {
configWithAntiCsrf = Object.assign({}, configWithAntiCsrf, {
Expand Down
4 changes: 4 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export default class AuthHttpRequest {
// to avoid race conditions
const preRequestIdToken = getIDFromCookie();
const antiCsrfToken = AntiCsrfToken.getToken(preRequestIdToken);
config = {
...config,
credentials: "include"
};
let configWithAntiCsrf: RequestInit | undefined = config;
if (antiCsrfToken !== undefined) {
configWithAntiCsrf = {
Expand Down

0 comments on commit 4b3d376

Please sign in to comment.