Repository navigation
fix(auth): check token on cluster switch and flag the cached device list - #240
Merged
Merged
Conversation
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>
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.
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
cache.Managerrecords the last refresh error for the current cluster (LastRefreshError). It resets on a switch or token change and ignores cancelled refreshes.GET /api/device-cachenow reportsrefreshFailedandauthFailed.loadUserInforaises the Update Token banner on a 401 fromGetEnterprise.activateClusternow clearsauthErrorat 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 onauthFailed.enterpriseanduserInfoare cleared on a switch, so the header shows the new cluster's name.Testing
go vet ./...andgo test ./...pass, including newLastRefreshErrortests.authFailedfrom the poll, andrefreshFailedwithout an auth failure. The build succeeds.🤖 Generated with Claude Code