-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat(cli): reauthenticate user in case of invalid token #3643
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, I'd suggest @kdhamric taking a look at the video to see if it matches what he wants
flags.EnvironmentID = envID | ||
} | ||
|
||
spew.Dump(flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spew 🔫
} | ||
|
||
func handleAuthError(ctx context.Context) { | ||
ui.DefaultUI.Warning("Your authentication token has expired, please log in again.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this handles environment tokens expiration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. I didn't test that case, but this mechanism is triggered whenever the server returns a 401. So if an expired token throws a 401, then this will be triggered.
I watched the video - looks awesome @schoren ! |
This PR improves the error handling when the server does not accept the JWT token for whatever reason (corrupted config file, expired token, anything that makes the server return a 401 code).
When an auth error happens, the authentication flow begins, and the issued command is automatically rerun with the new credentials.
For the case of the
start
cmd, this new behaviour was causing the cli to show 2 times the org/env selector: once for the new auth and another one for thestart
command (it shows the selector when started unless org/env are passed via flags).To overcome this issue, I added some context magic to pass the values around in a relatively seamless way so this command can pick the values and not ask the user 2 times.
Changes
Fixes
Checklist
Loom video
https://www.loom.com/share/cf956f7d668f475baa22678d4ac6a7bf