1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(instances): the VM page reads the user's rights from the VM's own record

It looked the user's ownership up by the VM's name on its compute; names
are not unique there (a VM renamed outside the panel and a migration can
leave two), which gave a server error or another VM's rights on the page.
This commit is contained in:
catborise 2026-11-05 16:37:18 +03:00
parent d97e44b77f
commit 623e9874cb
2 changed files with 45 additions and 5 deletions

View file

@ -288,11 +288,7 @@ def _instance_page(request, pk, instance, compute):
console_listener_addresses = settings.QEMU_CONSOLE_LISTENER_ADDRESSES
ipv4_addresses = [address for net in instance.networks for address in net["ipv4"] or []]
try:
userinstance = UserInstance.objects.get(
instance__compute_id=compute.id,
instance__name=instance.name,
user__id=request.user.id,
)
userinstance = UserInstance.objects.get(instance=instance, user=request.user)
except UserInstance.DoesNotExist:
userinstance = None
# The page offers only what the backend allows this user (get_instance