Platoniq/decidim-verifications-direct_verifications

View on GitHub
app/permissions/decidim/direct_verifications/admin/permissions.rb

Summary

Maintainability
A
25 mins
Test Coverage
# frozen_string_literal: true

module Decidim
  module DirectVerifications
    module Admin
      class Permissions < Decidim::DefaultPermissions
        def permissions
          return permission_action if permission_action.scope != :admin
          return permission_action unless user
          return permission_action unless user.admin?

          toggle_allow(Decidim::DirectVerifications.manage_workflows.map(&:to_s).include?(context.fetch(:name).to_s)) if permission_action.subject == :direct_authorization

          permission_action
        end
      end
    end
  end
end