Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Fix coder login on Windows #310

Merged
merged 3 commits into from
Apr 5, 2021
Merged

Fix coder login on Windows #310

merged 3 commits into from
Apr 5, 2021

Conversation

bpmct
Copy link
Member

@bpmct bpmct commented Apr 5, 2021

See CH10090 https://app.clubhouse.io/coder/story/10090/coder-login-fails-windows-command-prompt-1-17-2

Switches to bufio.Scanner for reading the token. Thanks @jawnsy for the guidance

before:

C:\Users\victo>coder login https://dev.coding.pics
Your browser has been opened to visit:

        https://dev.coding.pics/internal-auth?show_token=true

Paste token here: REDACTED
fatal: login error: ping API with credentials: call api: Execute request: "Get \"https://dev.coding.pics/api/v0/users/me\": net/http: invalid header field value \"REDACTED\\r\" for key Session-Token"


C:\Users\victo> coder version

coder version v1.17.2 go1.15.10 windows/386

Edit: tested on Windows 10 and OSX to confirm it worked

@bpmct bpmct requested a review from jawnsy April 5, 2021 13:17
Copy link
Contributor

@jawnsy jawnsy left a comment

Choose a reason for hiding this comment

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

looks great, thanks for fixing this!

fmt.Print("Paste token here: ")
var token string
scanner := bufio.NewScanner(cmd.InOrStdin())
scanner.Scan()
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest using _ = scanner.Scan() to make it clear that we're ignoring the return value intentionally

@bpmct bpmct enabled auto-merge (squash) April 5, 2021 14:14
@bpmct bpmct merged commit 996a3cd into master Apr 5, 2021
@bpmct bpmct deleted the fix-auth-windows branch April 5, 2021 14:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants