Commits

genbit  committed 082d2ed

re #1 - fixed custom fields validation error

  • Participants
  • Parent commits f1d563e

Comments (0)

Files changed (1)

File lib/custom_value_path.rb

   
   module InstanceMethods
     def validate_ssh
+      config_file = "#{RAILS_ROOT}/config/mercurial-server-dirs.yml"
+      config = YAML.load_file(config_file)[RAILS_ENV]
+      return true until custom_field[:name] == config['ssh_key_field_name']
       begin
         return true if value == ""
         keys = value.split("\n\n")
-				for key in keys do
-					type, blob, host = key.split(/ /)
-					raise Net::SSH::Exception, "public key is not valid (hostname: #{host.to_s})" if blob.nil?
+	for key in keys do
+          type, blob, host = key.split(/ /)
+          raise Net::SSH::Exception, "public key is not valid (hostname: #{host.to_s})" if blob.nil?
           blob = blob.unpack("m*").first
-				  reader = Net::SSH::Buffer.new(blob)
-					reader.read_key or raise OpenSSL::PKey::PKeyError, "not a public key (hostname: #{host.to_s})"
-				end
+	  reader = Net::SSH::Buffer.new(blob)
+	  reader.read_key or raise OpenSSL::PKey::PKeyError, "not a public key (hostname: #{host.to_s})"
+	end
       rescue
         errors.add(:value, :invalid)
       end