Allow usual users to download their private keys
This commit is contained in:
parent
96affc6c9f
commit
230085b964
2 changed files with 5 additions and 1 deletions
|
@ -2,7 +2,9 @@
|
|||
|
||||
class PrivateKeyPolicy < ApplicationPolicy
|
||||
def show?
|
||||
account&.superuser? &&
|
||||
return false if account.nil?
|
||||
|
||||
(account.superuser? || account == record.account) &&
|
||||
record.exist? &&
|
||||
params[:private_key_pem_secret].present?
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
class PrivateKey
|
||||
attr_reader :asymmetric_key
|
||||
|
||||
delegate :account, to: :asymmetric_key
|
||||
|
||||
def self.policy_class
|
||||
'PrivateKeyPolicy'
|
||||
end
|
||||
|
|
Reference in a new issue