Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Conversation

ehmicky
Copy link
Contributor

@ehmicky ehmicky commented Dec 11, 2020

This refactors the logic related to accessToken.

@ehmicky ehmicky added the type: chore work needed to keep the product and development running smoothly label Dec 11, 2020
@ehmicky ehmicky requested a review from erezrokah December 11, 2020 15:58
@ehmicky ehmicky self-assigned this Dec 11, 2020
"lodash.set": "^4.3.2",
"micro-api-client": "^3.3.0",
"node-fetch": "^2.2.0",
"omit.js": "^2.0.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was previously removed by #93
However, omit.js does not use core-js anymore, so we can use it again.

}

get accessToken() {
return (get(this, 'defaultHeaders.Authorization') || '').replace('Bearer ', '') || null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this.defaultHeaders is set by the constuctors, so we can assume it is defined.

const {
defaultHeaders: { Authorization },
} = this
if (typeof Authorization !== 'string' || !Authorization.startsWith('Bearer ')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic is slightly different, but seems to capture the actual intent. @erezrokah What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this looks much better

@erezrokah erezrokah merged commit d2d95bc into master Dec 13, 2020
@erezrokah erezrokah deleted the chore/access-token branch December 13, 2020 11:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

type: chore work needed to keep the product and development running smoothly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants