fix(desktop): scope account access to owning client and extend identity verification
Backend CI / Backend (push) Successful in 14m18s
Backend CI / Backend (push) Successful in 14m18s
Restrict account tracking, probing, and health reporting to accounts owned by the current client (client_id match). Extend identity-match verification to bilibili, juejin, and smzdm so session validity is confirmed locally rather than deferred to remote health state. Server-side account view now uses stored client_id as authoritative owner instead of presence data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -557,26 +557,19 @@ func (s *DesktopAccountService) buildDesktopAccountView(
|
||||
var clientLastSeenAt *time.Time
|
||||
var clientDeviceName *string
|
||||
|
||||
resolvedClientID := account.ClientID
|
||||
if presenceClientMap != nil {
|
||||
if activeClientID, ok := presenceClientMap[account.DesktopID]; ok {
|
||||
resolvedClientID = &activeClientID
|
||||
}
|
||||
}
|
||||
|
||||
if resolvedClientID != nil {
|
||||
value := resolvedClientID.String()
|
||||
if account.ClientID != nil {
|
||||
value := account.ClientID.String()
|
||||
clientID = &value
|
||||
|
||||
online := false
|
||||
clientOnline = &online
|
||||
|
||||
if clientMap != nil {
|
||||
if client, ok := clientMap[*resolvedClientID]; ok && client != nil {
|
||||
if client, ok := clientMap[*account.ClientID]; ok && client != nil {
|
||||
clientLastSeenAt = client.LastSeenAt
|
||||
clientDeviceName = client.DeviceName
|
||||
if presenceClientMap != nil {
|
||||
if activeClientID, ok := presenceClientMap[account.DesktopID]; ok && activeClientID == *resolvedClientID {
|
||||
if activeClientID, ok := presenceClientMap[account.DesktopID]; ok && activeClientID == *account.ClientID {
|
||||
online = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestResolveDesktopClientOnline_StaleHeartbeatIsOffline(t *testing.T) {
|
||||
assert.False(t, online)
|
||||
}
|
||||
|
||||
func TestBuildDesktopAccountView_PrefersAccountPresenceClient(t *testing.T) {
|
||||
func TestBuildDesktopAccountView_StoredClientOwnershipWinsOverPresence(t *testing.T) {
|
||||
service := &DesktopAccountService{}
|
||||
accountID := uuid.New()
|
||||
staleClientID := uuid.New()
|
||||
@@ -75,14 +75,14 @@ func TestBuildDesktopAccountView_PrefersAccountPresenceClient(t *testing.T) {
|
||||
)
|
||||
|
||||
if assert.NotNil(t, view.ClientID) {
|
||||
assert.Equal(t, activeClientID.String(), *view.ClientID)
|
||||
assert.Equal(t, staleClientID.String(), *view.ClientID)
|
||||
}
|
||||
if assert.NotNil(t, view.ClientOnline) {
|
||||
assert.True(t, *view.ClientOnline)
|
||||
assert.False(t, *view.ClientOnline)
|
||||
}
|
||||
assert.Equal(t, "4181862206", view.PlatformUID)
|
||||
assert.Equal(t, &lastSeen, view.ClientLastSeenAt)
|
||||
assert.Equal(t, &deviceName, view.ClientDeviceName)
|
||||
assert.Nil(t, view.ClientLastSeenAt)
|
||||
assert.Nil(t, view.ClientDeviceName)
|
||||
}
|
||||
|
||||
func TestBuildDesktopAccountView_FallsBackToStoredClientWhenNoPresence(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user