Commit 37dcfb6e authored by Rubén Dávila's avatar Rubén Dávila

Delegate #key to parent when working with a GPG subkey

The content returned by #key is important when veryfying the signature,
so given we don't want to repeat it in the database for GPG subkeys we
need to delegate it to the parent.
parent 62d54034
......@@ -8,6 +8,7 @@ class GpgKey < ActiveRecord::Base
sha_attribute :fingerprint
belongs_to :user
belongs_to :parent, class_name: 'GpgKey'
has_many :gpg_signatures
has_many :subkeys, class_name: 'GpgKey', foreign_key: :parent_id, dependent: :destroy
......@@ -48,6 +49,10 @@ class GpgKey < ActiveRecord::Base
super&.upcase
end
def key
parent_id? ? parent.key : super
end
def key=(value)
super(value&.strip)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment