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:
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index ff601966c26..f66aa4fb329 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -5,6 +5,9 @@ require 'digest/md5'
class Key < ApplicationRecord
include AfterCommitQueue
include Sortable
+ include Sha256Attribute
+
+ sha256_attribute :fingerprint_sha256
belongs_to :user
@@ -34,6 +37,8 @@ class Key < ApplicationRecord
after_destroy :post_destroy_hook
after_destroy :refresh_user_cache
+ alias_attribute :fingerprint_md5, :fingerprint
+
def self.regular_keys
where(type: ['Key', nil])
end
@@ -114,10 +119,12 @@ class Key < ApplicationRecord
def generate_fingerprint
self.fingerprint = nil
+ self.fingerprint_sha256 = nil
return unless public_key.valid?
- self.fingerprint = public_key.fingerprint
+ self.fingerprint_md5 = public_key.fingerprint
+ self.fingerprint_sha256 = public_key.fingerprint("SHA256").gsub("SHA256:", "")
end
def key_meets_restrictions