diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-09-27 06:10:10 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 16:25:27 +0300 |
commit | 37dcfb6e31a65d487424c0bf73874aabb2e69020 (patch) | |
tree | e46a4bab396d7df062de45a04dc55448d7b2c106 /app/models/gpg_key.rb | |
parent | 62d540340120baac7fa432108a7847cbc2a1cbe5 (diff) |
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.
Diffstat (limited to 'app/models/gpg_key.rb')
-rw-r--r-- | app/models/gpg_key.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb index cbf01183969..683efcebee9 100644 --- a/app/models/gpg_key.rb +++ b/app/models/gpg_key.rb @@ -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 |