Closed CodingDoug closed 1 year ago
If there is a token in env, all auth commands should fail saying that auth commands aren't effective when a token is in env.
Do you see any problem with just giving a warning telling the user that there is an env var token?
Do you see any problem with just giving a warning telling the user that there is an env var token?
By this, you mean the command still does its work, but with warning output first thing? For login that's seems unlikely to be effective since running the command immediately pops up a browser window, and you wouldn't see the warning until auth completes and the user returns to the CLI. And even then, they still might miss the warning, focusing instead of the success result. It might be better to simply fail ASAP and ask them reckon with the env var before doing anything else.
I think what @athoscouto is suggesting and I think I agree with it is:
TURSO_API_TOKEN
env variable (or from a flag if that's the case).That should remove all confusion.
@haaawk OK, that's starting to overlap a bit with the sibling issue #271, which is elaborating a bit on this suggestion.
My suggestion is actually the other way around. Allow auth commands normally, with a big warning saying that there is an env var set, which takes precedence over the token manipulated by the login command. Other commands work as they do now.
Allow auth commands normally, with a big warning saying that there is an env var set, which takes precedence over the token manipulated by the login command.
I think the only way this works out for login is if the warning message comes after the success message for the reason I mentioned earlier.
Assuming the user is already signed in with a token that works:
At this point, we have a token in env, nothing in settings.json, and commands requiring auth are working OK.
However, the following sequence of commands don't make sense given this context:
Is that response accurate? I'm implicitly logged in by way of env token.
At this point, there are two tokens in the system, env and settings.json. Auth login went ahead and did its thing without regard to env.
Which token was responsible for allowing this command to work? It's unclear.
The fact that the command still works after logout could be confusing. The CLI is now back to using the first token, but we've received no acknowledgement about this.
Proposal:
-t
, similar to above.Even better, if the CLI can decode the token, for any command that requires a token:
turso auth login
to get a new one.