mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11:46:49 +00:00
fix(computes): editing a compute keeps its password unless a new one is given
The TCP and TLS compute forms never show the stored password, so the field is empty on every edit. Saving the form without typing the password again replaced it with nothing, and the next connection to the host failed to authenticate. An empty password field on an edit now keeps the stored password; a new value replaces it.
This commit is contained in:
parent
490b337453
commit
1ce7dbf18e
2 changed files with 38 additions and 2 deletions
|
|
@ -7,7 +7,15 @@ from computes.models import Compute
|
|||
from .validators import validate_hostname
|
||||
|
||||
|
||||
class TcpComputeForm(forms.ModelForm):
|
||||
class KeepPasswordMixin:
|
||||
"""The form never shows the stored password: left empty on an edit, it
|
||||
stays as it is."""
|
||||
|
||||
def clean_password(self):
|
||||
return self.cleaned_data["password"] or self.instance.password
|
||||
|
||||
|
||||
class TcpComputeForm(KeepPasswordMixin, forms.ModelForm):
|
||||
hostname = forms.CharField(validators=[validate_hostname])
|
||||
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_TCP)
|
||||
|
||||
|
|
@ -26,7 +34,7 @@ class SshComputeForm(forms.ModelForm):
|
|||
exclude = ["password"]
|
||||
|
||||
|
||||
class TlsComputeForm(forms.ModelForm):
|
||||
class TlsComputeForm(KeepPasswordMixin, forms.ModelForm):
|
||||
hostname = forms.CharField(validators=[validate_hostname])
|
||||
type = forms.IntegerField(widget=forms.HiddenInput, initial=CONN_TLS)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue