Skip to content

fix(auth): check token on cluster switch and flag the cached device list - #240

Merged
sergey-zededa merged 1 commit into
mainfrom
fix/auth-check-on-cluster-switch
Nov 2, 2026
Merged

sergey-zededa merged 1 commit into
mainfrom
fix/auth-check-on-cluster-switch

Conversation

@sergey-zededa

Copy link
Copy Markdown
Owner

Problem

After switching to a cluster with an expired API token, the main screen looked valid and current. The token banner only appeared once a device's details were opened, and the header kept the previous cluster's enterprise name. The auth popup was also see-through over the device list.

Changes

  • Backend: cache.Manager records the last refresh error for the current cluster (LastRefreshError). It resets on a switch or token change and ignores cancelled refreshes. GET /api/device-cache now reports refreshFailed and authFailed.
  • Immediate check: loadUserInfo raises the Update Token banner on a 401 from GetEnterprise. activateCluster now clears authError at the start of the switch instead of after the check, so the check's result is no longer wiped out. The list poll also raises the banner on authFailed.
  • Stale list: a "Cached list, updated X ago" note with an Update Token link. The status column is muted and the footer count is marked "(cached)".
  • Header: enterprise and userInfo are cleared on a switch, so the header shows the new cluster's name.
  • Popups: the auth banner and the inline re-auth banner now sit their tint on an opaque panel colour.

Testing

  • go vet ./... and go test ./... pass, including new LastRefreshError tests.
  • Frontend: 201 tests pass, including new tests for the switch to a rejected token, authFailed from the poll, and refreshFailed without an auth failure. The build succeeds.

🤖 Generated with Claude Code

Switching to a cluster with an expired API token left the main screen
looking current: background refresh 401s were only logged, the device
cache endpoint always succeeded, and activateCluster cleared authError
after loadUserInfo had started.

- cache.Manager records the last refresh error for the current cluster;
  /api/device-cache reports refreshFailed / authFailed
- the list poll and loadUserInfo raise the Update Token banner on a 401
- while stale, the list shows a "Cached list, updated ..." note, mutes
  the status column and marks the footer count as cached
- clear enterprise/user info on switch so the header shows the new
  cluster instead of the previous one
- make the auth and re-auth popups opaque so the device list no longer
  shows through them

Signed-off-by: sergey-zededa <sergey@zededa.com>
@sergey-zededa
sergey-zededa merged commit 94f8a3e into main Nov 2, 2026
6 checks passed
@sergey-zededa
sergey-zededa deleted the fix/auth-check-on-cluster-switch branch November 2, 2026 08:12
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.

1 participant