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
|
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Reference in a new issue