Prevent local authority objects to be despawned on disconnections

I have a multiplayer game where users have control of some elements in the scene, so I grant them local player authority from the server. However, when the player disconnects these objects are despawned from the server. I want to resign the local authority from the player and give the ownership back to the server.

I tried the solution suggested in this post, but conn.clientOwnedObjects is empty, so I used this approach instead:

public class CustomNetworkManager : NetworkManager {

	public override void OnServerDisconnect(NetworkConnection conn) {
		base.OnServerDisconnect(conn);

		// Remove authority to players that disconnect the match so they don't disappear from the scene
		NetworkIdentity[] networkObjects = FindObjectsOfType<NetworkIdentity>();
 
		foreach (NetworkIdentity netIdentity in networkObjects) {
			if (netIdentity.clientAuthorityOwner == conn && netIdentity.GetComponent<Player>() == null) {
				netIdentity.RemoveClientAuthority(conn);
			}
		}
	}
}

While debugging the server, I can see how clientAuthorityOwner becomes null and hasAuthority becomes true, so the objects are correctly unassigned from the disconnected player. However, these objects are still removed from the scene.

Is there anything I am missing?

It looks that the objects are already being scheduled for destruction when calling super.OnServerDisconnect(), so moving that line to the end of the script fixed it. In addition, now conn.clientOwnedObjects works as expected again, so I refactored the script a little to use that method again. The result is the same, but it looks cleaner to me:

public class CustomNetworkManager : NetworkManager {

	public override void OnServerDisconnect(NetworkConnection conn) {
		// Remove authority to players that disconnect the match so they don't disappear
		List<NetworkInstanceId> networkIds = new List<NetworkInstanceId>(conn.clientOwnedObjects);
 
		foreach (NetworkInstanceId netId in networkIds) {
			GameObject gameObject = NetworkServer.FindLocalObject(netId);
			NetworkIdentity netIdentity = gameObject.GetComponent<NetworkIdentity>();
			bool isPlayer = netIdentity.GetComponent<Player>() != null;
			if (!isPlayer) {
				netIdentity.RemoveClientAuthority(conn);
			}
		}
 
		base.OnServerDisconnect(conn);
	}
}