diff --git a/management/server/peer.go b/management/server/peer.go index 5246e1fdc..a357adfe6 100644 --- a/management/server/peer.go +++ b/management/server/peer.go @@ -263,8 +263,7 @@ func (am *DefaultAccountManager) UpdatePeer(ctx context.Context, accountID, user return nil, err } - expired, _ := peer.LoginExpired(account.Settings.PeerLoginExpiration) - if peerLabelUpdated || (expired && peer.LoginExpirationEnabled) { + if peerLabelUpdated { am.updateAccountPeers(ctx, account) } diff --git a/management/server/peer_test.go b/management/server/peer_test.go index b8506bc50..7b2180bf0 100644 --- a/management/server/peer_test.go +++ b/management/server/peer_test.go @@ -1435,31 +1435,6 @@ func TestPeerAccountPeersUpdate(t *testing.T) { } }) - // Updating expired peer and peer expiration is enabled should update account peers and send peer update - t.Run("updating expired peer and peer expiration is enabled", func(t *testing.T) { - err = manager.Store.SavePeerStatus(account.Id, peer4.ID, nbpeer.PeerStatus{ - Connected: false, - LastSeen: time.Now().Add(-48 * time.Hour), - LoginExpired: true, - }) - require.NoError(t, err) - - done := make(chan struct{}) - go func() { - peerShouldReceiveUpdate(t, updMsg) - close(done) - }() - - _, err = manager.UpdatePeer(context.Background(), account.Id, userID, peer4) - require.NoError(t, err) - - select { - case <-done: - case <-time.After(time.Second): - t.Error("timeout waiting for peerShouldReceiveUpdate") - } - }) - // Deleting peer with linked group to policy should update account peers and send peer update t.Run("deleting peer with linked group to policy", func(t *testing.T) { done := make(chan struct{}) diff --git a/management/server/user.go b/management/server/user.go index a14dcde09..9fdd3a6ee 100644 --- a/management/server/user.go +++ b/management/server/user.go @@ -827,7 +827,7 @@ func (am *DefaultAccountManager) SaveOrAddUsers(ctx context.Context, accountID, return nil, err } - if areUsersLinkedToPeers(account, userIDs) && account.Settings.GroupsPropagationEnabled { + if account.Settings.GroupsPropagationEnabled && areUsersLinkedToPeers(account, userIDs) { am.updateAccountPeers(ctx, account) } @@ -1213,7 +1213,7 @@ func (am *DefaultAccountManager) DeleteRegularUsers(ctx context.Context, account continue } - if hadPeers && !updateAccountPeers { + if hadPeers { updateAccountPeers = true } diff --git a/management/server/user_test.go b/management/server/user_test.go index 3f7f814a0..d4f560a54 100644 --- a/management/server/user_test.go +++ b/management/server/user_test.go @@ -1301,7 +1301,7 @@ func TestUserAccountPeersUpdate(t *testing.T) { }) // Creating a new regular user should not update account peers and not send peer update - t.Run("creating new regular user", func(t *testing.T) { + t.Run("creating new regular user with no groups", func(t *testing.T) { done := make(chan struct{}) go func() { peerShouldNotReceiveUpdate(t, updMsg)