diff --git a/app/policies/private_key_policy.rb b/app/policies/private_key_policy.rb index 6f08910..e7df983 100644 --- a/app/policies/private_key_policy.rb +++ b/app/policies/private_key_policy.rb @@ -2,10 +2,13 @@ class PrivateKeyPolicy < ApplicationPolicy def show? + show_alert? && record.exist? + end + + def show_alert? return false if account.nil? - (account.superuser? || account == record.account) && - record.exist? && - params[:private_key_pem_secret].present? + params[:private_key_pem_secret].present? && + (account.superuser? || account == record.account) end end diff --git a/app/views/private_keys/_alert.html.erb b/app/views/private_keys/_alert.html.erb index 91ba6d5..d7ab38e 100644 --- a/app/views/private_keys/_alert.html.erb +++ b/app/views/private_keys/_alert.html.erb @@ -1,36 +1,40 @@ -<% if policy(PrivateKey.new(asymmetric_key)).show? %> - + <% end %> <% end %>