gitlab-org--gitlab-foss/app/models/project_import_data.rb

24 lines
743 B
Ruby
Raw Normal View History

require 'carrierwave/orm/activerecord'
class ProjectImportData < ActiveRecord::Base
belongs_to :project
2016-04-11 09:13:51 +00:00
attr_encrypted :credentials,
key: Gitlab::Application.secrets.db_key_base,
marshal: true,
encode: true,
mode: :per_attribute_iv_and_salt,
insecure_mode: true,
algorithm: 'aes-256-cbc'
serialize :data, JSON # rubocop:disable Cop/ActiveRecordSerialize
validates :project, presence: true
2016-04-01 10:04:41 +00:00
before_validation :symbolize_credentials
def symbolize_credentials
2016-04-11 09:13:51 +00:00
# bang doesn't work here - attr_encrypted makes it not to work
2016-04-06 08:36:30 +00:00
self.credentials = self.credentials.deep_symbolize_keys unless self.credentials.blank?
2016-04-01 10:04:41 +00:00
end
end