Sha256: 7c85c1b8188ba1bdade10502af9bb4bf05762c723b0af6ebbd7550e23dc516b5

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module Verifications
    # Common logic to renew authorizations
    module Renewable
      extend ActiveSupport::Concern
      included do
        def renew
          enforce_permission_to(:renew, :authorization, authorization:)

          DestroyUserAuthorization.call(authorization) do
            on(:ok, authorization) do
              flash[:notice] = t("authorizations.destroy.success", scope: "decidim.verifications")
              redirect_to new_authorization_path(handler: authorization.name)
            end

            on(:invalid) do
              flash[:alert] = t("authorizations.destroy.error", scope: "decidim.verifications")
              redirect_to authorizations_path
            end
          end
        end

        def renew_modal
          enforce_permission_to(:renew, :authorization, authorization:)

          respond_to do |format|
            format.html { render layout: nil }
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-verifications-0.29.1 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.28.4 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.29.0 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.28.3 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.29.0.rc4 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.29.0.rc3 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.29.0.rc2 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.29.0.rc1 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.28.2 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.28.1 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.28.0 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.28.0.rc5 app/controllers/concerns/decidim/verifications/renewable.rb
decidim-verifications-0.28.0.rc4 app/controllers/concerns/decidim/verifications/renewable.rb