Repository navigation
Name the saved token's server in device console and shell - #35
Merged
Merged
Conversation
device console and device shell checked for an empty token themselves, so when the saved token was for another server they said "not authenticated" instead of which server the token is for. Both now share newAuthedClient's check through requireToken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #33, now that it and #31 are merged.
#33 made nh refuse to send a saved token to a server other than the one it was saved for, and made
newAuthedClientreturncfg.TokenErr, which names the token's server.device consoleanddevice shellopen a websocket rather than an API client, and they checked for an empty token themselves. So with a token saved for another server, they saidnot authenticated: run nh user auth or set NERVES_HUB_TOKENinstead.Change
cmd/helpers.go: the token check is nowrequireToken(cfg), whichnewAuthedClientcalls.cmd/device_console.go:runDeviceTerminalSession, which bothdevice consoleanddevice shelluse, callsrequireTokentoo. They now fail with the samesaved token is for https://…error as every other command, still before checking for a terminal or dialling.No other command checks
cfg.Tokenitself. The other direct comparisons in the repo are on API response values.Tests
TestTerminalSessionsNameTheSavedTokensServerincmd/token_server_test.gocovers console and shell with a token saved for another server. It fails without the change, with the old "not authenticated" error.TestDeviceConsoleRequiresTokenandTestDeviceShellRequiresTokenstill pass. When no token is saved at all, the message is unchanged.go test ./...,go vet ./...andgofmt -l .are clean.🤖 Generated with Claude Code