Esempio n. 1
0
    def clean_public_key(self):
        public_key = self.cleaned_data['public_key']
        if self.instance.public_key and public_key == self.instance.public_key:
            msg = _('Public key should not be the same as your old one.')
            raise forms.ValidationError(msg)

        if public_key and not validate_ssh_public_key(public_key):
            raise forms.ValidationError(_('Not a valid ssh public key'))
        return public_key
Esempio n. 2
0
 def validate_public_key(value):
     if not validate_ssh_public_key(value):
         raise serializers.ValidationError(_('Not a valid ssh public key'))
     return value
Esempio n. 3
0
 def validate__public_key(value):
     if not validate_ssh_public_key(value):
         raise serializers.ValidationError(_('Not a valid ssh public key'))
     return value
Esempio n. 4
0
 def validate_public_key(self, public_key):
     if self.instance and self.instance.can_update_ssh_key():
         if not validate_ssh_public_key(public_key):
             raise serializers.ValidationError(_('Not a valid ssh public key'))
         return public_key
     return None