1
0
Fork 0

Allow usual users to download their private keys

This commit is contained in:
Alex Kotov 2019-09-14 00:32:43 +05:00
parent 96affc6c9f
commit 230085b964
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 5 additions and 1 deletions

View file

@ -2,7 +2,9 @@
class PrivateKeyPolicy < ApplicationPolicy class PrivateKeyPolicy < ApplicationPolicy
def show? def show?
account&.superuser? && return false if account.nil?
(account.superuser? || account == record.account) &&
record.exist? && record.exist? &&
params[:private_key_pem_secret].present? params[:private_key_pem_secret].present?
end end

View file

@ -3,6 +3,8 @@
class PrivateKey class PrivateKey
attr_reader :asymmetric_key attr_reader :asymmetric_key
delegate :account, to: :asymmetric_key
def self.policy_class def self.policy_class
'PrivateKeyPolicy' 'PrivateKeyPolicy'
end end