Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2017-09-27 06:10:10 +0300
committerRubén Dávila <ruben@gitlab.com>2017-10-05 16:25:27 +0300
commit37dcfb6e31a65d487424c0bf73874aabb2e69020 (patch)
treee46a4bab396d7df062de45a04dc55448d7b2c106 /app/models/gpg_key.rb
parent62d540340120baac7fa432108a7847cbc2a1cbe5 (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.rb5
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