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: improve authentication logging and warnings #645

Merged
merged 1 commit into from
Mar 19, 2022

Conversation

petebacondarwin
Copy link
Contributor

  • If a user has previously logged in via Wrangler 1 with an API token, we now display a helpful warning.
  • When logging in and out, we no longer display the path to the internal user auh config file.
  • When logging in, we now display an initial message to indicate the authentication flow is starting.

Fixes #526

@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2022

🦋 Changeset detected

Latest commit: 26a709b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2009312857/npm-package-wrangler-645

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/645/npm-package-wrangler-645

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2009312857/npm-package-wrangler-645 dev path/to/script.js

packages/wrangler/src/__tests__/logout.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/user.tsx Outdated Show resolved Hide resolved
@@ -365,6 +372,13 @@ function throwIfNotInitialised() {

export function getAPIToken(): string | undefined {
throwIfNotInitialised();
if (LocalState.api_token) {
console.warn(
"It looks like you have used Wrangler 1's `config` command to login with an API token.\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

tempted to just ignore the field and proceed as if the user isn't logged in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is what we do at the moment, and it was causing confusion. See #526

Hence this PR.

- If a user has previously logged in via Wrangler 1 with an API token, we now display a helpful warning.
- When logging in and out, we no longer display the path to the internal user auh config file.
- When logging in, we now display an initial message to indicate the authentication flow is starting.

Fixes [cloudflare#526](cloudflare#526)
@petebacondarwin petebacondarwin merged commit 61aea30 into cloudflare:main Mar 19, 2022
@petebacondarwin petebacondarwin deleted the api-token-warning branch March 19, 2022 19:46
@github-actions github-actions bot mentioned this pull request Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API tokens do not work in config/default.toml
3 participants