fix: recover from unauthorized error in @netlify/config call #1810
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- 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
andlogout
).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 toapi.listAccountsForUser
andapi.getCurrentUser
(currently it only exists forapi.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)