diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 18:08:10 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 18:08:10 +0000 |
commit | 175b4fa261259ab0d033482d10bb4159fee8e538 (patch) | |
tree | e1f1dba5e41177f11ffded5a505e0e7f692b8df5 /app/models/key.rb | |
parent | 4eea104c69e59f6fa53c7bc15b986c69f29b60c8 (diff) | |
download | gitlab-ce-175b4fa261259ab0d033482d10bb4159fee8e538.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/key.rb')
-rw-r--r-- | app/models/key.rb | 9 |
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 |