Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Conversation

douglashall
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Oct 17, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling e9f9b9a on douglashall/csrf into 0a370df on master.

@douglashall douglashall force-pushed the douglashall/csrf branch 2 times, most recently from cd9c3fc to 761eca5 Compare October 22, 2018 21:19
@douglashall douglashall force-pushed the douglashall/csrf branch 3 times, most recently from 770b2f6 to 45b336e Compare November 7, 2018 21:53
@douglashall douglashall force-pushed the douglashall/csrf branch 2 times, most recently from 78c538d to 400045e Compare November 9, 2018 22:08
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks.

};

authenticatedAPIClient.getCsrfToken = apiHostname =>
authenticatedAPIClient.get(`https://${apiHostname}${authenticatedAPIClient.csrfTokenApiPath}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need http support for local dev environment? Probably not a blocker, but just curious about local development.

const url = new Url(request.url);
const { hostname } = url;
const csrfToken = csrfTokens[hostname];
if (!csrfToken) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe simpler to follow if you start with if (csrfToken) and set header and return early. Then the rest of the method would be used for the queue and promise.

const originalRequest = request;
const isAuthUrl = authenticatedAPIClient.isAuthUrl(originalRequest.url);
const isAccessTokenExpired = authenticatedAPIClient.isAccessTokenExpired();
if (!isAuthUrl && isAccessTokenExpired) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Similar comment in terms of possibly inverting the if and returning earlier.

});
expects(client);

if (expectHeaderSet) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need an else?

@douglashall douglashall force-pushed the douglashall/csrf branch 2 times, most recently from 18ca4e9 to d91a223 Compare November 14, 2018 15:48
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to make any of the remaining changes as you see fit. Thanks.

@douglashall douglashall merged commit ab48d0b into master Nov 14, 2018
@douglashall douglashall deleted the douglashall/csrf branch November 14, 2018 16:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants