Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: recover from unauthorized error in @netlify/config call #1810

Merged
merged 3 commits into from
Jan 26, 2021

Conversation

eduardoboucas
Copy link
Member

- Summary

Since #1722, CLI is making an API call for every command, even for the ones that don't require API data (e.g. login and logout).

As a consequence, users might get locked in their accounts if they have an invalid/revoked token. If they try to login or logout, CLI will still try to use their existing token and fail before the command they're trying to execute has a change to succeed.

This PR adds a temporary solution that re-tries a call to @netlify/config without a token if a call with the existing token fails.

It also adds a message to the status command checking for an unauthorised call to api.listAccountsForUser and api.getCurrentUser (currently it only exists for api.getSite. We should abstract this behaviour, so that any time we retrieve any user data with an invalid token, we're able to display a helpful error message (and possibly log the user out automatically?).

- Description for the changelog

fix: recover from unauthorized error in @netlify/config call

- A picture of a cute animal (not mandatory but encouraged)

maxresdefault

@eduardoboucas eduardoboucas requested a review from a team as a code owner January 26, 2021 12:48
@eduardoboucas eduardoboucas added the type: bug code to address defects in shipped code label Jan 26, 2021
// any API calls.
//
// @todo Replace this with a mechanism for calling `resolveConfig` with more granularity (i.e. having
// the option to say that we don't need API data.)
Copy link
Contributor

@ehmicky ehmicky Jan 26, 2021

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that works too. Done in 1c8cc6d.

Thanks @ehmicky! 👊🏻

@erezrokah erezrokah merged commit 8d38f78 into master Jan 26, 2021
@erezrokah erezrokah deleted the fix/api-auth branch January 26, 2021 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants