Do SSH key validation only if the user doesn't have an existing key and

the user has input some value in the add ssh key field
This commit is contained in:
PCoder 2019-06-25 03:48:29 +02:00
commit feeb102f92
3 changed files with 32 additions and 23 deletions

View file

@ -187,7 +187,8 @@ class UserHostingKeyForm(forms.ModelForm):
alerts the user of it.
:return:
"""
if 'generate' in self.request.POST:
if ('generate' in self.request.POST
or not self.fields['public_key'].required):
return self.data.get('public_key')
KEY_ERROR_MESSAGE = _("Please input a proper SSH key")
openssh_pubkey_str = self.data.get('public_key').strip()