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.
This commit is contained in:
parent
62d5403401
commit
37dcfb6e31
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue