mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
fix(instances): a template's console settings cannot be changed by a POST
A template's page has no console settings form (it is cloned, not run), but update_console still took a direct POST from a staff owner with is_change and is_vnc, or from a superuser. can_manage_console now refuses every template, so the page and the view use one rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
d34b1eb2bf
commit
0cee65805d
4 changed files with 18 additions and 7 deletions
|
|
@ -463,15 +463,13 @@ def can_manage_console(user, instance):
|
|||
"""
|
||||
Who may see and change a VM's console settings, including its VNC
|
||||
password: an active superuser, or an active owner with both is_change and
|
||||
is_vnc; on a template only a staff owner (as get_instance(perm_type="change")).
|
||||
is_vnc. No one on a template: it is cloned, not run.
|
||||
is_staff and the global view_instances permission alone do not count.
|
||||
"""
|
||||
if not user.is_active:
|
||||
if not user.is_active or instance.is_template:
|
||||
return False
|
||||
if user.is_superuser:
|
||||
return True
|
||||
if instance.is_template and not user.is_staff:
|
||||
return False
|
||||
return UserInstance.objects.filter(
|
||||
instance=instance, user=user, is_change=True, is_vnc=True
|
||||
).exists()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue