예제 #1
0
파일: forms.py 프로젝트: ezc/jumpserver
    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
예제 #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
예제 #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
예제 #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